$nice $rsync "${rsync_options[@]}" $filelist_flag $excludes $batch_option $orig $dest_path | tee -a $log
if [ "$?" != "0" ]; then
fatal "Rsync error when trying to transfer $SECTION"
fi
The problem is that due to piping the rsync output to "tee" program the handler will never trigger the fatal message:
When running the following commands we get an exit status 1:
rsync = --non-existing-bla --syntax-error-coming up
echo $?
But we get 0 when piping to @tee@:
rsync = --non-existing-bla --syntax-error-coming up | tee test_file
echo $?
(from redmine: created on 2012-04-17, closed on 2012-05-15)
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Child items ...
Show closed items
Linked items 0
Link issues together to show that they're related.
Learn more.
Using a @set -o pipefail@ bash statament to ensure that a non-zero exit status is always forwarded to @$?@.
I'm more inclined to the third sollution as doesn't break any existing functionality and would not conflict with any changes from current pending patches.
The following example returns @1@ as expected:
#!/bin/bash
set -o pipefail
rsync = --non-existing-bla --syntax-error-coming up | tee test_file
echo $?
Do you think I should also disable @pipefail@ after issuing the command or I should also check if @pipefail@ is set in beforehand and restore it's default value after I use it? Maybe that's the way to go as all backupninja actions are sourced.
Do you think I should also disable @pipefail@ after issuing the command or I should also check if @pipefail@ is set in beforehand and restore it's default value after I use it? Maybe that's the way to go as all backupninja actions are sourced.
However, I prefer set pipefail / unset pipefail being tightly wrapped around the smallest possible amount of code that actually needs it, rather than globally as your branch does: we need to increase chances, if not to make sure, the initial state is reset if things go wrong somehow.
However, I prefer set pipefail / unset pipefail being tightly wrapped around the smallest possible amount of code that actually needs it, rather than globally as your branch does: we need to increase chances, if not to make sure, the initial state is reset if things go wrong somehow.
In the end, @set_pipefail@ / @restore_pipefail@ look overkill, don't they?
Yes, but they keep the overall coding style. If you want, I can present an alternative commit where the set/restore pipefail are handled in the main procedure, but it would mix inner details with other generic function calls IMO.
Fair enough. Note that I was not suggesting to move the current pipefail set/restore code to the main procedure, but merely to replace the calls to these functions by @set -o pipefail@ / @set +o pipefail@ and be done with it.
I tried merging your branch, but it conflicts with current master.
Please rebase.
Fair enough. Note that I was not suggesting to move the current pipefail set/restore code to the main procedure, but merely to replace the calls to these functions by @set -o pipefail@ / @set +o pipefail@ and be done with it.
I tried merging your branch, but it conflicts with current master.
Please rebase.