X-Git-Url: http://gitweb.hugovil.com/?a=blobdiff_plain;f=functions;h=ecd34f04cf8b44403614c79ee52a94bb937f6ee0;hb=1eb363044c6ee3115e62736aed4403b750082b44;hp=2ccd9658354d4bc8a4cb3cc949003d1c335d7e83;hpb=63214057431c558e4c216c4e3ea12c7b06bd4950;p=hvlinux.git diff --git a/functions b/functions index 2ccd965..ecd34f0 100644 --- 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 }