Quote:
Originally Posted by topcat8
Hi,
I am trying to test the exit status of the cleartool lsvtree statement below, but it doesn't seem to be working due to the tail pipe, which it is testing instead. Is there a way around this without adding a tonne of new code?
[...]
|
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