Hi,
I wanted to enable error code reporting for piped processes. This should be doable by "set
-o pipeline on". The problem is it kills my $* array and defines $1="on".
$ bash -x /tmp/a.sh arg1 arg2 arg3
+ for f in $*
+ echo arg1
arg1
+ for f in $*
+ echo arg2
arg2
+ for f in $*
+ echo arg3
arg3
+ set -o pipefail on
+ for f in $*
+ echo on
on
$
I can work around by storing a $* copy before fiddling with set command.
$ cat /tmp/a.sh
#! /bin/sh
for f in $* ; do
echo $f
done
mybackup=$*
set -o pipefail on
for f in ${mybackup} ; do
echo $f
done
$
$ bash -x /tmp/a.sh arg1 arg2 arg3
+ for f in $*
+ echo arg1
arg1
+ for f in $*
+ echo arg2
arg2
+ for f in $*
+ echo arg3
arg3
+ mybackup='arg1 arg2 arg3'
+ set -o pipefail on
+ for f in ${mybackup}
+ echo arg1
arg1
+ for f in ${mybackup}
+ echo arg2
arg2
+ for f in ${mybackup}
+ echo arg3
arg3
$
I am on Gentoo Linux:
# emerge -pv app-shells/bash
These are the packages that would be merged, in order:
Calculating dependencies... done!
[ebuild R ] app-shells/bash-4.4_p5-r1::gentoo USE="net nls (readline) -afs
-bashlogger -examples -mem-scramble -plugins" 0 KiB
Thank you for comments,
Martin