Colin Watson wrote:
> I suggested a solution for this a while ago:
>
> ((echo hello world; false; echo $? >&3) | logger) 3>&1
>
> You then get the exit status on stdout. Generalizing a bit:
>
> to_syslog () {
> return "$((("$@"; echo $? >&3) | logger) 3>&1)"
> }
>
> This works for me in my tests using bash, anyway. Somebody might want to
> check that the "$(..."..."...)" construction works in dash.
That actually needs to have set +e inside the subshells. I'm using
similar code now (but it also checks the other end of the pipeline's
exit status) in linux-kernel-di.
ret=$(((
set +e
tar cfT - $tmpdir/module-list/$i
printf $? >&3
) | (
set +e
dir=$home/debian/$i-$version-di/lib/modules/$installedname/kernel
mkdir -p $dir
cd $dir
tar xf -
printf $? >&3
)) 3>&1)
if [ "$ret" != "00" ]; then
echo "tar failed" >&2
exit $ret
fi
--
see shy jo
Attachment:
signature.asc
Description: Digital signature