From 2ea4bed1c18f66312370eda737ac209661b7ba40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Andr=C3=A8s?= Date: Fri, 23 Feb 2018 01:35:17 +0100 Subject: [PATCH] Updated SC2155 (markdown) --- SC2155.md | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) 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