Timeline for How can I get exit status of subshell?
Current License: CC BY-SA 4.0
5 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Nov 16, 2019 at 17:26 | comment | added | user313992 |
btw, you got you quoting backwards: you should quote the ${PIPESTATUS[@]} in echo "${PIPESTATUS[@]}", but you don't have to quote the $(...) in process=$(false | true).
|
|
| Nov 16, 2019 at 17:22 | comment | added | user313992 |
... which is "interesting", since there are no nice solutions, only ugly kludges. For instance, this will use a tempfile to get the data out, while leaving stdout and stderr undisturbed: t=$(mktemp); exec 3>$t 4<$t; rm "$t"; out=$(false | true | false | echo hmm; echo -n "${PIPESTATUS[@]}" >&3); readarray -td' ' st <&4; exec 3>&- 4<&-; echo "out=$out; st=(${st[*]})". Related: Redirect STDERR and STDOUT to different variables without temporary files
|
|
| Nov 16, 2019 at 16:56 | comment | added | user313992 |
well, you do the echo ${PIPESTATUS} inside the command substitution subshell ;-) I guess your question is more about how to capture output other than stdout from a command substitution.
|
|
| Nov 16, 2019 at 16:55 | comment | added | jesse_b |
process="$(false | true ; echo ${PIPESTATUS[@]} >&2)" or process="$(false | true ; echo ${PIPESTATUS[@]} >/dev/tty)"
|
|
| Nov 16, 2019 at 16:52 | history | asked | Sopalajo de Arrierez | CC BY-SA 4.0 |