mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-10-03 11:19:45 +08:00
Avoid exporting empty env
@@ -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.
|
||||
|
Reference in New Issue
Block a user