Finding the last arg

Hans Mulder hansm at cs.kun.nl
Fri Jan 4 08:47:45 AEST 1991


In article <1991Jan2.174157.21530 at usenet.ins.cwru.edu> chet at po.CWRU.Edu writes:
>Here's a short list of what was added to the v7 sh for the System V.2 sh:

[ stuff deleted ]

>exit status of a pipeline was defined to be the exit status of the last command

Nit-pick:
Both the v7 and the SVR2 sh manuals mention that
"the exit status of a pipeline is the exit status of the last command".

The problem is the the word "last" is ambiguous.

The v7 sh takes it to mean "last to terminate", SVR2 interprets it as
"rightmost".

Thus the pipeline "sleep 10 | false" would be considered successful by
the v7 shell (since the sleep terminates last, and successfully), while
the SVR2 sh considers it unsuccessful.

I think the latter behaviour is more useful.  For one thing, it makes
"if foo | grep -s bar" work right 100% of the time.


Happy New Year,

Hans Mulder	hansm at cs.kun.nl



More information about the Comp.unix.shell mailing list