In bash
, the PIPESTATUS
array holds the return values of commands in a pipeline.
Suppose that in the pipeline cmd1 | cmd2 | cmd3
, the second command returns an error. Checking PIPESTATUS
gives the index of the failed command, but how might one print the name of the command itself, cmd2
?
It would be nice to show the arguments to cmd2
as well, but I will accept an answer that only prints the command name.