Quote:
Originally Posted by radoulov
bash and ksh93 have the pipefail option:
Code:
bash 3.2.25(17)$ ls x|tail
ls: cannot access x: No such file or directory
bash 3.2.25(17)$ echo $?
0
bash 3.2.25(17)$ set -o pipefail
bash 3.2.25(17)$ ls x|tail
ls: cannot access x: No such file or directory
bash 3.2.25(17)$ echo $?
2
bash and zsh have the PIPESTATUS/pipestatus array/variable:
Code:
bash 3.2.25(17)$ ls x|tail
ls: cannot access x: No such file or directory
bash 3.2.25(17)$ echo $PIPESTATUS
2
bash 3.2.25(17)$ ls x|tail
ls: cannot access x: No such file or directory
bash 3.2.25(17)$ echo ${PIPESTATUS[@]}
2 0
Code:
zsh 4.3.4% ls x|tail
ls: cannot access x: No such file or directory
zsh 4.3.4% echo $pipestatus
2 0
|
set -o pipefail doesnt seem to work on SunOS 5.8
Code:
bash-2.03$ uname
SunOS
bash-2.03$ set -o pipefail
bash: set: pipefail: unknown option name
echo $PIPESTATUS works on bash but not on ksh
Code:
bash-2.05$ ls -l rakesh | tail -5
rakesh: No such file or directory
bash-2.05$ echo $PIPESTATUS
2