From d2292fdc1e11c3e96d84e49e3784edd62bde0d66 Mon Sep 17 00:00:00 2001 From: Eisuke Kawashima Date: Tue, 29 Jul 2025 20:44:44 +0900 Subject: [PATCH] Updated SC2016 (markdown) --- SC2016.md | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/SC2016.md b/SC2016.md index 313dbc8..523233b 100644 --- a/SC2016.md +++ b/SC2016.md @@ -30,19 +30,19 @@ dialog --msgbox "Filename $file may not contain any of: "'`&;"\#%$' 10 70 If you know that you want the expression literally without expansion, you can [[ignore]] this message: -``` +```sh # We want this to output $PATH without expansion # shellcheck disable=SC2016 echo 'PATH=$PATH:/usr/local/bin' >> ~/.bashrc ``` -``` +```sh # We also want this variable to expand "$BASH_SOURCE:$LINE..." during an execution trace. # shellcheck disable=SC2016 PS4='+$BASH_SOURCE:$LINENO:$FUNCNAME: ' ``` -``` +```sh # We want to control which environment variables envsubst replaces # shellcheck disable=SC2016 envsubst '${SERVICE_HOST}:${SERVICE_PORT}' config.template > config @@ -50,11 +50,10 @@ envsubst '${SERVICE_HOST}:${SERVICE_PORT}' config.template > config ShellCheck also does not warn about escaped expansions in double quotes: -``` +```sh echo "PATH=\$PATH:/usr/local/bin" >> ~/.bashrc ``` - This suggestion is primarily meant to help newbies who assume single and double quotes are basically the same, like in Python and JavaScript. It's not at all meant to discourage experienced users from using single quotes in general. If you are well aware of the difference, please do not hesitate to permanently disable this suggestion with `disable=SC2016` in your `.shellcheckrc`. ShellCheck tries to increase the signal-to-noise ratio of this warning by ignoring certain well known commands that frequently expect literal dollar signs, such as `sh` and `perl`. However, there's a long tail of less common commands and flags that also frequently expect `$`s, and it's not in ShellCheck's scope to try to keep track of them all. When you come across such a command, please [[ignore]] the suggestion, either permanently or for that one instance.