From 8e190620dba6f7cc398aa865c9dabe0161f63567 Mon Sep 17 00:00:00 2001 From: Thibault Guittet Date: Tue, 25 Jan 2022 16:24:46 +0000 Subject: [PATCH] Update modules/ROOT/pages/programming-languages/Shell.adoc Fix typo and add `PIPESTATUS` for checking return values of commands executed within pipes. --- modules/ROOT/pages/programming-languages/Shell.adoc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/ROOT/pages/programming-languages/Shell.adoc b/modules/ROOT/pages/programming-languages/Shell.adoc index 684c846..b4dab74 100644 --- a/modules/ROOT/pages/programming-languages/Shell.adoc +++ b/modules/ROOT/pages/programming-languages/Shell.adoc @@ -226,7 +226,7 @@ expansion) of the right-hand side of the assignment operation. See <>. Shell scripts which use integer or array variables should be -rewritten in another, more suitable language. Se <>. +rewritten in another, more suitable language. See <>. [[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