mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-08-21 05:53:38 +08:00
Warn about non-posix function names like x-y
This commit is contained in:
@@ -601,6 +601,7 @@ prop_checkBashisms35= verifyNot checkBashisms "#!/bin/dash\nlocal foo"
|
|||||||
prop_checkBashisms36= verifyNot checkBashisms "#!/bin/dash\nread -p foo -r bar"
|
prop_checkBashisms36= verifyNot checkBashisms "#!/bin/dash\nread -p foo -r bar"
|
||||||
prop_checkBashisms37= verifyNot checkBashisms "HOSTNAME=foo; echo $HOSTNAME"
|
prop_checkBashisms37= verifyNot checkBashisms "HOSTNAME=foo; echo $HOSTNAME"
|
||||||
prop_checkBashisms38= verify checkBashisms "RANDOM=9; echo $RANDOM"
|
prop_checkBashisms38= verify checkBashisms "RANDOM=9; echo $RANDOM"
|
||||||
|
prop_checkBashisms39= verify checkBashisms "foo-bar() { true; }"
|
||||||
checkBashisms params = bashism
|
checkBashisms params = bashism
|
||||||
where
|
where
|
||||||
isDash = shellType params == Dash
|
isDash = shellType params == Dash
|
||||||
@@ -665,6 +666,9 @@ checkBashisms params = bashism
|
|||||||
bashism (T_CoProc id _ _) =
|
bashism (T_CoProc id _ _) =
|
||||||
warnMsg id "coproc is"
|
warnMsg id "coproc is"
|
||||||
|
|
||||||
|
bashism (T_Function id _ _ str _) | not (isVariableName str) =
|
||||||
|
warnMsg id "naming functions outside [a-zA-Z_][a-zA-Z0-9_]* is"
|
||||||
|
|
||||||
bashism t@(T_SimpleCommand _ _ (cmd:arg:_))
|
bashism t@(T_SimpleCommand _ _ (cmd:arg:_))
|
||||||
| t `isCommand` "echo" && "-" `isPrefixOf` argString =
|
| t `isCommand` "echo" && "-" `isPrefixOf` argString =
|
||||||
unless ("--" `isPrefixOf` argString) $ -- echo "-----"
|
unless ("--" `isPrefixOf` argString) $ -- echo "-----"
|
||||||
|
Reference in New Issue
Block a user