diff --git a/SC2155.md b/SC2155.md index b445f17..4ac4324 100644 --- a/SC2155.md +++ b/SC2155.md @@ -43,6 +43,16 @@ local foo foo=$(mycmd) ``` +### Rationale + +The exit status of the command is overridden by the exit status of the creation the local variable. For example: + +```bash +$ f() { local foo=$(false) || echo foo; }; f +$ f() { local foo; foo=$(false) || echo foo; }; f +foo +``` + ### Problematic code in the case of `readonly`: ```sh