mirror of
https://github.com/koalaman/shellcheck
synced 2025-07-08 05:51:09 -07:00
Warn about suspicious IFS, such as IFS="\n"
This commit is contained in:
parent
680f838c63
commit
c4181d45d2
2 changed files with 23 additions and 1 deletions
|
@ -965,10 +965,12 @@ readNormalEscaped = called "escaped char" $ do
|
|||
do
|
||||
next <- anyChar
|
||||
case escapedChar next of
|
||||
Just name -> parseNoteAt pos WarningC 1012 $ "\\" ++ [next] ++ " is just literal '" ++ [next] ++ "' here. For " ++ name ++ ", use \"$(printf \"\\" ++ [next] ++ "\")\"."
|
||||
Just name -> parseNoteAt pos WarningC 1012 $ "\\" ++ [next] ++ " is just literal '" ++ [next] ++ "' here. For " ++ name ++ ", use " ++ (alternative next) ++ " instead."
|
||||
Nothing -> parseNoteAt pos InfoC 1001 $ "This \\" ++ [next] ++ " will be a regular '" ++ [next] ++ "' in this context."
|
||||
return [next]
|
||||
where
|
||||
alternative 'n' = "a quoted, literal line feed"
|
||||
alternative t = "\"$(printf \"\\" ++ [t] ++ "\")\""
|
||||
escapedChar 'n' = Just "line feed"
|
||||
escapedChar 't' = Just "tab"
|
||||
escapedChar 'r' = Just "carriage return"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue