summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDieter Plaetinck <dieter@plaetinck.be>2009-08-01 22:15:34 +0200
committerDieter Plaetinck <dieter@plaetinck.be>2009-08-01 22:15:34 +0200
commit44bc9f54734d9280c71959e56189044141bc1640 (patch)
treed50047247d1e14a59d73b4dd5b6966c17699013a /src
parent985105effdc8c7d80ad9592cf13ff245e71ef826 (diff)
make run background/controlled exitcodes more robust & bugfree
Diffstat (limited to 'src')
-rw-r--r--src/core/libs/lib-misc.sh7
-rw-r--r--src/core/libs/lib-software.sh10
2 files changed, 7 insertions, 10 deletions
diff --git a/src/core/libs/lib-misc.sh b/src/core/libs/lib-misc.sh
index e96e4d2..eec5a2e 100644
--- a/src/core/libs/lib-misc.sh
+++ b/src/core/libs/lib-misc.sh
@@ -20,11 +20,11 @@ run_controlled ()
run_background $1 "$2" $3
follow_progress " $4 " $3 $BACKGROUND_PID # dia mode ignores the pid. cli uses it to know how long it must do tail -f
wait_for $1 $FOLLOW_PID
+ CONTROLLED_EXIT=$BACKGROUND_EXIT
else
notify "$4"
- var_exit=${1}_exitcode
eval "$2" >>$3 2>&1
- read $var_exit <<< $?
+ CONTROLLED_EXIT=$?
fi
}
@@ -47,9 +47,8 @@ run_background ()
debug 'MISC' "run_background starting $1: $2 >>$3 2>&1"
[ -f $3 ] && echo -e "\n\n\n" >>$3
echo "STARTING $1 . Executing $2 >>$3 2>&1\n" >> $3;
- var_exit=${1}_exitcode
eval "$2" >>$3 2>&1
- read $var_exit <<< $?
+ $BACKGROUND_EXIT=$?
debug 'MISC' "run_background done with $1: exitcode (\$$1_exitcode): ${!var_exit} .Logfile $3"
echo >> $3
rm -f $RUNTIME_DIR/aif-$1-running
diff --git a/src/core/libs/lib-software.sh b/src/core/libs/lib-software.sh
index 6b0527f..93a3c15 100644
--- a/src/core/libs/lib-software.sh
+++ b/src/core/libs/lib-software.sh
@@ -14,9 +14,8 @@ run_mkinitcpio()
target_special_fs off
# alert the user to fatal errors
- # TODO: on the next line, bash gives '[: -ne: unary operator expected'. seen on 2009-07-21
- [ $mkinitcpio_exitcode -ne 0 ] && show_warning "MKINITCPIO FAILED - SYSTEM MAY NOT BOOT" "$TMP_MKINITCPIO_LOG" text
- return $mkinitcpio_exitcode
+ [ $CONTROLLED_EXIT -ne 0 ] && show_warning "MKINITCPIO FAILED - SYSTEM MAY NOT BOOT" "$TMP_MKINITCPIO_LOG" text
+ return $CONTROLLED_EXIT
}
@@ -49,8 +48,7 @@ installpkg() {
run_controlled pacman_installpkg "$PACMAN_TARGET --noconfirm -S $ALL_PACKAGES" $TMP_PACMAN_LOG "Installing... Please Wait"
local _result=''
- # TODO: on the next line, bash gives '[: -ne: unary operator expected'. seen on 2009-07-21
- if [ ${pacman_installpkg_exitcode} -ne 0 ]; then
+ if [ $CONTROLLED_EXIT -ne 0 ]; then
_result="Installation Failed (see errors below)"
echo -e "\nPackage Installation FAILED." >>$TMP_PACMAN_LOG
else
@@ -63,7 +61,7 @@ installpkg() {
target_special_fs off
sync
- return ${pacman_installpkg_exitcode}
+ return $CONTROLLED_EXIT
}