-
Notifications
You must be signed in to change notification settings - Fork 1.8k
SC1001
koalaman edited this page Jul 5, 2017
·
9 revisions
# Want literal backslash
echo Yay \o/
# Want linefeed
greeting=Hello\nWorld
# Want other characters
carriagereturn=\r
echo 'Yay \o/'
greeting='Hello
World'
carriagereturn=$(printf '\r')
You have escaped something that has no special meaning when escaped. The backslash will be simply be ignored.
If the backslash was supposed to be literal, single quote or escape it.
If you wanted it to expand to something, rewrite the expression. For linefeeds (\n
), put them literally in quotes. For other characters, use POSIX printf
or bash/ksh $'...'
.
None. ShellCheck (as of 2017-07-03, commit 31bb02d6) will not warn when the first letter of a command is unnecessarily escaped, as this is frequently used to suppress aliases interactively.