Difference between revisions of "PIPESTATUS"

From Wiki 4 Men
Jump to navigation Jump to search
(Created page with "$ cat /etc/passwd | rev | false $ echo ${PIPESTATUS[@]} 0 141 1 {{BASH}}")
 
 
Line 2: Line 2:
 
$ echo ${PIPESTATUS[@]}
 
$ echo ${PIPESTATUS[@]}
 
0 141 1
 
0 141 1
  +
  +
Test an entire pipe for non-zero exit statuses:
  +
  +
[[ -n ${PIPESTATUS[*]/0/} ]] && echo "Error Will Robinson!"
  +
   
 
{{BASH}}
 
{{BASH}}
  +
{{Draft}}

Latest revision as of 02:28, 14 February 2024

$ cat /etc/passwd | rev | false $ echo ${PIPESTATUS[@]} 0 141 1

Test an entire pipe for non-zero exit statuses:

[[ -n ${PIPESTATUS[*]/0/} ]] && echo "Error Will Robinson!"

This is a draft article and so will not be published on A Voice for Men or appear in random article selections. Wiki4Men is looking for trustworthy editors that can turn draft articles in to featured articles. Information on how to apply is on the Main Page.