Updated SC2148 (markdown)

Vidar Holen
2019-01-20 13:13:45 -08:00
parent a0267b3a4a
commit 1d391cdfae

@@ -24,12 +24,16 @@ echo "$RANDOM" # Supported in bash. No warnings.
Different shells support different features. To give effective advice, ShellCheck needs to know which shell your script is going to run on. You will get a different numbers of warnings about different things depending on your target shell. Different shells support different features. To give effective advice, ShellCheck needs to know which shell your script is going to run on. You will get a different numbers of warnings about different things depending on your target shell.
ShellCheck normally determines your target shell from the shebang (having e.g. `#!/bin/sh` as the first line). The shell can also be specified from the CLI with `-s`, e.g. `shellcheck -s sh file`. If you add a shebang (e.g. `#!/bin/bash` as the first line), the OS will use this interpreter when the script is executed, and ShellCheck will use this shell when offering advice.
If you don't specify shebang nor `-s`, ShellCheck gives this message and proceeds with some default (`bash`). If you for any reason can't or won't add a shebang, there are multiple other ways to let shellcheck know which shell you're coding for:
* Specify the shell using the `-s` or `--shell` flag, e.g. `shellcheck -s bash myfile`
* Use a shellcheck [[directive]], adding `# shellcheck shell=ksh` before the first command in the file.
* Give the script a `.bash`, `.ksh` or `.dash` extension (`.sh` will not assume `--shell=sh` since it's so generic)
Note that this error can not be ignored with a [[directive]]. It is not a suggestion to improve your script, but a warning that ShellCheck lacks information it needs to be helpful. Note that this error can not be ignored with a [[directive]]. It is not a suggestion to improve your script, but a warning that ShellCheck lacks information it needs to be helpful.
### Exceptions ### Exceptions
None. Please either add a shebang or use `-s`. None. Please either add a shebang, directive, extension or use `-s`.