Update modules/ROOT/pages/programming-languages/Shell.adoc

Fix typo and add `PIPESTATUS` for checking return values of commands executed within pipes.
This commit is contained in:
Thibault Guittet 2022-01-25 16:24:46 +00:00
parent 0c15018e17
commit 8e190620db

View file

@ -226,7 +226,7 @@ expansion) of the right-hand side of the assignment operation.
See <<sect-Defensive_Coding-Shell-Arithmetic>>.
Shell scripts which use integer or array variables should be
rewritten in another, more suitable language. Se <<sect-Defensive_Coding-Shell-Alternatives>>.
rewritten in another, more suitable language. See <<sect-Defensive_Coding-Shell-Alternatives>>.
[[sect-Defensive_Coding-Shell-Obscure]]
=== Other Obscurities
@ -291,6 +291,7 @@ the first failed command. However, failures in pipes
(“pass:attributes[{blank}]`command1 | command2`pass:attributes[{blank}]”) are only detected for the
last command in the pipe, errors in previous commands are ignored.
This can be changed by invoking “pass:attributes[{blank}]`set -o pipefail`pass:attributes[{blank}]”.
Alternatively, return codes for previous commands in pipes can be accessed in the (“pass:attributes[{blank}]`${PIPESTATUS[X]}`pass:attributes[{blank}]”) array.
Due to architectural limitations, only the process that spawned
the entire pipe can check for failures in individual commands;
it is not possible for a process to tell if the process feeding