mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-10-03 19:29:44 +08:00
Updated SC1000: $ is not used specially and should therefore be escaped. (markdown)
@@ -1,3 +1,13 @@
|
|||||||
|
# $ is not used specially and should therefore be escaped.
|
||||||
|
|
||||||
|
### Problematic code:
|
||||||
|
|
||||||
|
echo "$"
|
||||||
|
|
||||||
|
### Correct code:
|
||||||
|
|
||||||
|
echo "\$"
|
||||||
|
|
||||||
### Rationale:
|
### Rationale:
|
||||||
`$` is special in double quotes, but there are some cases where it's interpreted literally:
|
`$` is special in double quotes, but there are some cases where it's interpreted literally:
|
||||||
|
|
||||||
@@ -5,11 +15,3 @@
|
|||||||
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'"`).
|
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.
|
To avoid relying on strange and shell specific behavior, any `$` intended to be literal should be escaped with a backslash.
|
||||||
|
|
||||||
### Problematic sample code:
|
|
||||||
|
|
||||||
echo "$"
|
|
||||||
|
|
||||||
### Correct sample code:
|
|
||||||
|
|
||||||
echo "\$"
|
|
Reference in New Issue
Block a user