Skip to content

Files

Latest commit

 

History

History
28 lines (17 loc) · 654 Bytes

SC1000.md

File metadata and controls

28 lines (17 loc) · 654 Bytes

Pattern: Use of unescaped $

Issue: -

Description

$ 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.

Example of incorrect code:

echo "$"

Example of correct code:

echo "\$"

Further Reading