Skip to content
koalaman edited this page Nov 10, 2013 · 5 revisions

$ is not used specially and should therefore be escaped.

Problematic code:

echo "$"

Correct code:

echo "\$"

Rationale:

$ is special in double quotes, but there are some cases where it's interpreted literally:

  1. Following a backslash: echo "\$"
  2. In a context where the shell can't make sense of it, such as at the end of the string, ("foo$") or before some constructs ("$'foo'").

To avoid relying on strange and shell specific behavior, any $ intended to be literal should be escaped with a backslash.

ShellCheck

Each individual ShellCheck warning has its own wiki page like SC1000. Use GitHub Wiki's "Pages" feature above to find a specific one, or see Checks.

Clone this wiki locally