Discussion:
How to get the whole pipeline command?
(too old to reply)
Peng Yu
2018-12-04 17:16:02 UTC
Permalink
Hi,

In the following example, since the error is from the pipeline, I'd
expect the whole pipeline is printed. But it only prints the last
command in the pipeline, which actually finished correctly.

Is there a way to get the whole pipeline command ("false | true" in
this case)? Thanks.

$ cat main.sh
#!/usr/bin/env bash
# vim: set noexpandtab tabstop=2:

trap 'echo The running command is: "${BASH_COMMAND[@]}"' ERR
false | true
set -o pipefail
false | true
$ ./main.sh
The running command is: true
--
Regards,
Peng
Loading...