diff --git a/SC2155.md b/SC2155.md index b51fa92..44e2b25 100644 --- a/SC2155.md +++ b/SC2155.md @@ -1,6 +1,6 @@ ## Declare and assign separately to avoid masking return values. -### Problematic code: +### Problematic code in the case of `export`: ```sh export foo="$(mycmd)" @@ -29,3 +29,16 @@ 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. + +### Problematic code in the case of `local`: + +```sh +local foo="$(mycmd)" +``` + +### Correct code: + +```sh +local foo +foo=$(mycmd) +``` \ No newline at end of file