mirror of
https://github.com/koalaman/shellcheck
synced 2025-07-14 09:03:08 -07:00
Error on backslash in comment #2132
- Report error in case of a backspace in a comment Backspaces in comments are no good. In most cases they are the result of commenting out a longer line, that was broken down. This usually results in the shell treating the following lines as their own commands on their own lines instead of as parts of the longer, broken down line.
This commit is contained in:
parent
15ff87cf80
commit
d6bb8fc0d8
1 changed files with 6 additions and 1 deletions
|
@ -1039,9 +1039,14 @@ readComment = do
|
|||
unexpecting "shellcheck annotation" readAnnotationPrefix
|
||||
readAnyComment
|
||||
|
||||
prop_readAnyComment = isOk readAnyComment "# Comment"
|
||||
prop_readAnyComment1 = not $ isOk readAnyComment "# Comment \\\n"
|
||||
readAnyComment = do
|
||||
char '#'
|
||||
many $ noneOf "\r\n"
|
||||
comment <- many $ noneOf "\\\r\n"
|
||||
bs <- many $ oneOf "\\"
|
||||
unless (null bs) (fail "Backslash in or directly after comment")
|
||||
return comment
|
||||
|
||||
prop_readNormalWord = isOk readNormalWord "'foo'\"bar\"{1..3}baz$(lol)"
|
||||
prop_readNormalWord2 = isOk readNormalWord "foo**(foo)!!!(@@(bar))"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue