Avoid exporting empty env

Harshavardhana
2017-11-04 11:24:37 -07:00
parent c82895ac1d
commit e6abcc4d88

@@ -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.