diff --git a/SC2155.md b/SC2155.md index 4b7d1f6..a81e07c 100644 --- a/SC2155.md +++ b/SC2155.md @@ -19,16 +19,18 @@ In the original code, the return value of `mycmd` is ignored, and `export` will When first marked for export and assigned separately, the return value of the assignment will be that of `mycmd`. This avoids the problem. +Note that ShellCheck does not warn about masking of local read-only variables, such as `local -r foo=$(cmd)`, even though this also masks the return value. This is because the alternative `local foo; foo=$(cmd); local -r foo` is repetitive and cumbersome. + #### Exceptions: -If you intend to ignore the return value of an assignment, you can either ignore this warning or use +If you intend to ignore the return value of an assignment, you can either [[ignore]] this warning or use ```sh foo=$(mycmd) || true export foo ``` -Shellcheck does not warn about `export foo=bar` because `bar` is a literal and not a command substitution with an independent return value. It also does not warn about `local -r foo=$(cmd)`, where declaration and assignment must be in the same command. +Shellcheck does not warn about `export foo=bar` because `bar` is a literal and not a command substitution with an independent return value. ### Problematic code in the case of `local`: