From 0358090b3c06bebe0561468c025e768defaa63f7 Mon Sep 17 00:00:00 2001 From: Benjamin Gordon Date: Thu, 25 Apr 2019 09:32:20 -0600 Subject: [PATCH] Refactor definition of special variables. This ensures that the parser and other places that refer to special variables can use the same list. --- src/ShellCheck/Data.hs | 2 ++ src/ShellCheck/Parser.hs | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ShellCheck/Data.hs b/src/ShellCheck/Data.hs index cae07d3..1a994a3 100644 --- a/src/ShellCheck/Data.hs +++ b/src/ShellCheck/Data.hs @@ -47,6 +47,8 @@ variablesWithoutSpaces = specialVariablesWithoutSpaces ++ [ "COLUMNS", "HISTFILESIZE", "HISTSIZE", "LINES" ] +specialVariables = specialVariablesWithoutSpaces ++ ["@", "*"] + arrayVariables = [ "BASH_ALIASES", "BASH_ARGC", "BASH_ARGV", "BASH_CMDS", "BASH_LINENO", "BASH_REMATCH", "BASH_SOURCE", "BASH_VERSINFO", "COMP_WORDS", "COPROC", diff --git a/src/ShellCheck/Parser.hs b/src/ShellCheck/Parser.hs index a403bea..f5f62cd 100644 --- a/src/ShellCheck/Parser.hs +++ b/src/ShellCheck/Parser.hs @@ -69,7 +69,7 @@ variableChars = upper <|> lower <|> digit <|> oneOf "_" functionChars = variableChars <|> oneOf ":+?-./^@" -- Chars to allow in functions using the 'function' keyword extendedFunctionChars = functionChars <|> oneOf "[]*=!" -specialVariable = oneOf "@*#?-$!" +specialVariable = oneOf (concat specialVariables) paramSubSpecialChars = oneOf "/:+-=%" quotableChars = "|&;<>()\\ '\t\n\r\xA0" ++ doubleQuotableChars quotable = almostSpace <|> oneOf quotableChars