From e6abcc4d8889fff5a417cc9e8f0206d4394a9edb Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Sat, 4 Nov 2017 11:24:37 -0700 Subject: [PATCH] Avoid exporting empty env --- SC2155.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SC2155.md b/SC2155.md index f19caed..b51fa92 100644 --- a/SC2155.md +++ b/SC2155.md @@ -9,8 +9,8 @@ export foo="$(mycmd)" ### Correct code: ```sh -export foo foo=$(mycmd) +export foo ``` ### Rationale: @@ -24,8 +24,8 @@ When first marked for export and assigned separately, the return value of the as If you intend to ignore the return value of an assignment, you can either ignore this warning or use ```sh -export foo 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.