From 141f9bd535eb6b2501ccfe18a7034e9cbaa514d1 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 20 Oct 2006 11:27:09 +0200 Subject: [PATCH] Display correct return code --- ccollect.sh | 6 ++++-- test/return-value.sh | 7 +++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/ccollect.sh b/ccollect.sh index fca0a92..490f6e4 100755 --- a/ccollect.sh +++ b/ccollect.sh @@ -417,8 +417,10 @@ while [ "$i" -lt "$no_sources" ]; do rsync $ouropts $useropts "$source" "$abs_destination_dir" fi - if [ "$?" -ne 0 ]; then - echo "rsync reported error $?. The backup may be broken (see rsync errors)." + ret=$? + + if [ "$ret" -ne 0 ]; then + echo "rsync reported error $ret. The backup may be broken (see rsync errors)." fi echo "$($DDATE) Finished backup" diff --git a/test/return-value.sh b/test/return-value.sh index e91de9a..554def0 100755 --- a/test/return-value.sh +++ b/test/return-value.sh @@ -14,3 +14,10 @@ if [ "$ret" -ne 0 ]; then echo "$ret" fi +# if is true, ls is fales +if [ "foo" = "foo" ]; then + ls /surely-not-existent$$ 2>/dev/null +fi + +# but that's still the return of ls and not of fi +echo $?