mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-10-03 19:29:44 +08:00
Created SC2163 (markdown)
22
SC2163.md
Normal file
22
SC2163.md
Normal file
@@ -0,0 +1,22 @@
|
||||
## Exporting an expansion rather than a variable.
|
||||
|
||||
### Problematic code:
|
||||
|
||||
MYVAR=foo
|
||||
export $MYVAR
|
||||
|
||||
### Correct code:
|
||||
|
||||
MYVAR=foo
|
||||
export MYVAR
|
||||
|
||||
### Rationale:
|
||||
|
||||
`export` takes a variable name, but shellcheck has noticed that you give it an expanded variable instead. The problematic code does not export `MYVAR` but a variable called `foo` if any.
|
||||
|
||||
### Exceptions:
|
||||
|
||||
If you do want to export the variable's value, e.g. due to indirection, you can disable this message with a directive:
|
||||
|
||||
# shellcheck disable=SC2163
|
||||
export "$MYVAR"
|
Reference in New Issue
Block a user