My opinions on this subject: It's probably not worth changing the behavior, particularly since there is likely to be some small amount of code out there that depends on it.
The behavior in regard to ! is correct (as has been noted) because PIPESTATUS records the values of the commands in the pipeline, not of the pipeline as a whole. Someone noted that "! true | ! true" is a syntax error, which matches the documentation. Chet Ramey <chet.ra...@case.edu> writes: > Compound commands don't generally set PIPESTATUS. Multi-element pipelines > (the original purpose, because otherwise why bother), simple commands > (single-element pipelines) including shell builtins, and compound commands > that resemble simple commands (`[[', `((') set it. > > Yes, you can make the case that compound commands are pipelines, and, > according to the grammar, they are, but their status is always available > in $?, and they never have more than one status value. The documentation is (as of 5.1): PIPESTATUS An array variable (see Arrays below) containing a list of exit status values from the processes in the most-recently-executed foreground pipeline (which may contain only a single command). This needs to be modified to note that compound commands that are not one component of a multi-command pipeline do not cound as pipelines for setting PIPESTATUS. Exactly which compounds commands don't set PIPESTATUS is not obvious. E.g. "{...}" does not but "(...)" does. "processes" should probably be changed to "commands" as that's what they're called in the documentation. "most-recently-executed foreground pipeline" should be clarified as "most-recently-completed foreground pipeline". Dale