mirror of
https://github.com/koalaman/shellcheck
synced 2025-08-22 14:23:53 -07:00
Issue 1330 unsupported echo flags
Issue https://github.com/koalaman/shellcheck/issues/1330 Addresses false positives when quoted arguments to echo begin with what looks like a flag. Now, warn only when the first argument is a recognized echo flag when flags are unsupported.
This commit is contained in:
parent
ec6f9e4d49
commit
ecb7bbe0ea
1 changed files with 5 additions and 2 deletions
|
@ -145,6 +145,7 @@ prop_checkBashisms62 = verify checkBashisms "#!/bin/sh\nexport -f foo"
|
|||
prop_checkBashisms63 = verifyNot checkBashisms "#!/bin/sh\nexport -p"
|
||||
prop_checkBashisms64 = verify checkBashisms "#!/bin/sh\nreadonly -a"
|
||||
prop_checkBashisms65 = verifyNot checkBashisms "#!/bin/sh\nreadonly -p"
|
||||
prop_checkBashisms66 = verifyNot checkBashisms "#!/bin/sh\necho \"-n foo\""
|
||||
checkBashisms = ForShell [Sh, Dash] $ \t -> do
|
||||
params <- ask
|
||||
kludge params t
|
||||
|
@ -231,7 +232,7 @@ checkBashisms = ForShell [Sh, Dash] $ \t -> do
|
|||
warnMsg id "`<file` to read files is"
|
||||
|
||||
bashism t@(T_SimpleCommand _ _ (cmd:arg:_))
|
||||
| t `isCommand` "echo" && "-" `isPrefixOf` argString =
|
||||
| t `isCommand` "echo" && elem argString echoFlags =
|
||||
unless ("--" `isPrefixOf` argString) $ -- echo "-----"
|
||||
if isDash
|
||||
then
|
||||
|
@ -239,7 +240,9 @@ checkBashisms = ForShell [Sh, Dash] $ \t -> do
|
|||
warnMsg (getId arg) "echo flags besides -n"
|
||||
else
|
||||
warnMsg (getId arg) "echo flags are"
|
||||
where argString = concat $ oversimplify arg
|
||||
where
|
||||
argString = concat $ oversimplify arg
|
||||
echoFlags = ["-e", "-E", "-s", "-n"]
|
||||
bashism t@(T_SimpleCommand _ _ (cmd:arg:_))
|
||||
| t `isCommand` "exec" && "-" `isPrefixOf` concat (oversimplify arg) =
|
||||
warnMsg (getId arg) "exec flags are"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue