From 34b03040d9fdf59bf5e056336235456455e4aa62 Mon Sep 17 00:00:00 2001 From: Adrian Fluturel Date: Tue, 31 Dec 2024 04:48:19 +0100 Subject: [PATCH] Allow pound symbol only inside the function name --- src/ShellCheck/Parser.hs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/ShellCheck/Parser.hs b/src/ShellCheck/Parser.hs index f1ff26a..17107ba 100644 --- a/src/ShellCheck/Parser.hs +++ b/src/ShellCheck/Parser.hs @@ -66,7 +66,9 @@ singleQuote = char '\'' doubleQuote = char '"' variableStart = upper <|> lower <|> oneOf "_" variableChars = upper <|> lower <|> digit <|> oneOf "_" --- Chars to allow in function names +-- Chars to allow function names to start with +functionStartChars = variableChars <|> oneOf ":+?-./^@," +-- Chars to allow inside function names functionChars = variableChars <|> oneOf "#:+?-./^@," -- Chars to allow in functions using the 'function' keyword extendedFunctionChars = functionChars <|> oneOf "[]*=!" @@ -2768,7 +2770,7 @@ readFunctionDefinition = called "function" $ do string "function" whitespace spacing - name <- many1 extendedFunctionChars + name <- (:) <$> functionStartChars <*> many extendedFunctionChars spaces <- spacing hasParens <- wasIncluded readParens when (not hasParens && null spaces) $ @@ -2777,7 +2779,7 @@ readFunctionDefinition = called "function" $ do return $ \id -> T_Function id (FunctionKeyword True) (FunctionParentheses hasParens) name readWithoutFunction = try $ do - name <- many1 functionChars + name <- (:) <$> functionStartChars <*> many functionChars guard $ name /= "time" -- Interferes with time ( foo ) spacing readParens