The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #10 (permalink)  
Old 10-18-2007
rakeshou rakeshou is offline
Registered User
  
 

Join Date: May 2007
Posts: 75
set -o pipefail not available on sunos, $PIPESTATUS works on bash not on ksh

Quote:
Originally Posted by radoulov View Post
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