Updated SC2163 (markdown)

Vidar Holen
2018-02-17 17:07:06 -08:00
parent 7ccc10e4e3
commit 20f2166f78

@@ -1,4 +1,4 @@
## Exporting an expansion rather than a variable. ## This does not export 'FOO'. Remove $/${} for that, or use ${var?} to quiet.
### Problematic code: ### Problematic code:
@@ -20,9 +20,18 @@ export MYVAR
### Exceptions: ### Exceptions:
If you do want to export the variable's value, e.g. due to indirection, you can disable this message with a directive: If this is intentional and you do want to export `foo` instead of `MYVAR`, you can either use a directive:
```sh ```sh
# shellcheck disable=SC2163 # shellcheck disable=SC2163
export "$MYVAR" export "$MYVAR"
``` ```
Or after (but not including) version 0.4.7, take advantage of the fact that ShellCheck only warns when no parameter expansion modifiers are applied:
```sh
export "${MYVAR}" # ShellCheck warns
export "${MYVAR?}" # No warning
```
`${MYVAR?}` fails when `MYVAR` is unset, which is fine since `export` would have failed too. The main side effect is an improved runtime error message in that case.