mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-10-03 19:29:44 +08:00
Updated SC1001 (markdown)
12
SC1001.md
12
SC1001.md
@@ -6,11 +6,8 @@
|
|||||||
# Want literal backslash
|
# Want literal backslash
|
||||||
echo Yay \o/
|
echo Yay \o/
|
||||||
|
|
||||||
# Want linefeed
|
|
||||||
greeting=Hello\nWorld
|
|
||||||
|
|
||||||
# Want other characters
|
# Want other characters
|
||||||
carriagereturn=\r
|
bell=\a
|
||||||
```
|
```
|
||||||
|
|
||||||
### Correct code:
|
### Correct code:
|
||||||
@@ -18,10 +15,7 @@ carriagereturn=\r
|
|||||||
```sh
|
```sh
|
||||||
echo 'Yay \o/'
|
echo 'Yay \o/'
|
||||||
|
|
||||||
greeting='Hello
|
bell="$(printf '\a')"
|
||||||
World'
|
|
||||||
|
|
||||||
carriagereturn=$(printf '\r')
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Rationale:
|
### Rationale:
|
||||||
@@ -30,7 +24,7 @@ You have escaped something that has no special meaning when escaped. The backsla
|
|||||||
|
|
||||||
If the backslash was supposed to be literal, single quote or escape it.
|
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 `$'...'`.
|
If you wanted it to expand to something, rewrite the expression to use `printf` (or in bash, `$'\t'`). If the sequence in question is `\n`, `\t` or `\r`, you instead get a [[SC1012]] that describes this.
|
||||||
|
|
||||||
### Exceptions
|
### Exceptions
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user