Stage2 semble compléter ok
[hvlinux.git] / functions
index 2ccd965..ecd34f0 100644 (file)
--- a/functions
+++ b/functions
@@ -962,6 +962,29 @@ rscr()
     return $EXIT_SUCCESS
 }
 
+rcmd_trap_setup()
+{
+    exec 6>&1 # Save current "value" of stdout.
+    trap rcmd_trap_handler INT TERM EXIT ERR
+}
+
+rcmd_trap_end()
+{
+    trap - INT TERM EXIT ERR
+
+    # Restore global trap
+    #####hvtrap_setup
+}
+
+rcmd_trap_handler()
+{
+    exec 1>&6 6>&- # Restore stdout and close file descriptor #6.
+    print_status failure
+
+    ###rcmd_trap_end
+    ###exit 1
+}
+
 # Run command, no log
 # First  argument: Message to display during script
 # Second argument: command + arguments
@@ -982,10 +1005,21 @@ rcmd()
 
     display_checkbox_msg ${MSGSTRING}
 
+    rcmd_trap_setup
+
     echo ${CMD_WITH_ARGS} 1>> ${LFS_LOG_FILE}
 
+    if [ -n "${RCMD_NO_EXIT}" ]; then
+        set +e
+    fi
+    
     # Executing command
     ${CMD_WITH_ARGS} 1>> ${LFS_LOG_FILE} 2>&1
+
+    if [ -n "${RCMD_NO_EXIT}" ]; then
+        set -e
+    fi
+
     if [ $? -ne 0 ]; then
        print_status failure
         if [ -n "${RCMD_NO_EXIT}" ]; then
@@ -998,6 +1032,8 @@ rcmd()
     # Displaying build time after the package name
     print_status success
 
+    rcmd_trap_end
+
     return $EXIT_SUCCESS
 }