From 7415c9dcb7fc3daf39f8d56927b480304ab849e3 Mon Sep 17 00:00:00 2001 From: Vidar Holen Date: Sat, 31 Oct 2015 13:53:17 -0700 Subject: [PATCH] Warn about non-posix function names like x-y --- ShellCheck/Analytics.hs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ShellCheck/Analytics.hs b/ShellCheck/Analytics.hs index f8df27a..874757d 100644 --- a/ShellCheck/Analytics.hs +++ b/ShellCheck/Analytics.hs @@ -601,6 +601,7 @@ prop_checkBashisms35= verifyNot checkBashisms "#!/bin/dash\nlocal foo" prop_checkBashisms36= verifyNot checkBashisms "#!/bin/dash\nread -p foo -r bar" prop_checkBashisms37= verifyNot checkBashisms "HOSTNAME=foo; echo $HOSTNAME" prop_checkBashisms38= verify checkBashisms "RANDOM=9; echo $RANDOM" +prop_checkBashisms39= verify checkBashisms "foo-bar() { true; }" checkBashisms params = bashism where isDash = shellType params == Dash @@ -665,6 +666,9 @@ checkBashisms params = bashism bashism (T_CoProc id _ _) = 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:_)) | t `isCommand` "echo" && "-" `isPrefixOf` argString = unless ("--" `isPrefixOf` argString) $ -- echo "-----"