mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-08-21 20:47:02 +08:00
Save string read by T_ParamSubSpecialChar
This commit is contained in:
@@ -111,7 +111,7 @@ data Token =
|
|||||||
| T_NormalWord Id [Token]
|
| T_NormalWord Id [Token]
|
||||||
| T_OR_IF Id
|
| T_OR_IF Id
|
||||||
| T_OrIf Id (Token) (Token)
|
| T_OrIf Id (Token) (Token)
|
||||||
| T_ParamSubSpecialChar Id -- e.g. '%' in ${foo%bar} or '/' in ${foo/bar/baz}
|
| T_ParamSubSpecialChar Id String -- e.g. '%' in ${foo%bar} or '/' in ${foo/bar/baz}
|
||||||
| T_Pipeline Id [Token] [Token] -- [Pipe separators] [Commands]
|
| T_Pipeline Id [Token] [Token] -- [Pipe separators] [Commands]
|
||||||
| T_ProcSub Id String [Token]
|
| T_ProcSub Id String [Token]
|
||||||
| T_Rbrace Id
|
| T_Rbrace Id
|
||||||
@@ -320,7 +320,7 @@ getId t = case t of
|
|||||||
T_DollarBraced id _ -> id
|
T_DollarBraced id _ -> id
|
||||||
T_DollarArithmetic id _ -> id
|
T_DollarArithmetic id _ -> id
|
||||||
T_BraceExpansion id _ -> id
|
T_BraceExpansion id _ -> id
|
||||||
T_ParamSubSpecialChar id -> id
|
T_ParamSubSpecialChar id _ -> id
|
||||||
T_DollarBraceCommandExpansion id _ -> id
|
T_DollarBraceCommandExpansion id _ -> id
|
||||||
T_IoFile id _ _ -> id
|
T_IoFile id _ _ -> id
|
||||||
T_IoDuplicate id _ _ -> id
|
T_IoDuplicate id _ _ -> id
|
||||||
|
@@ -86,6 +86,7 @@ oversimplify token =
|
|||||||
(T_Glob _ s) -> [s]
|
(T_Glob _ s) -> [s]
|
||||||
(T_Pipeline _ _ [x]) -> oversimplify x
|
(T_Pipeline _ _ [x]) -> oversimplify x
|
||||||
(T_Literal _ x) -> [x]
|
(T_Literal _ x) -> [x]
|
||||||
|
(T_ParamSubSpecialChar _ x) -> [x]
|
||||||
(T_SimpleCommand _ vars words) -> concatMap oversimplify words
|
(T_SimpleCommand _ vars words) -> concatMap oversimplify words
|
||||||
(T_Redirecting _ _ foo) -> oversimplify foo
|
(T_Redirecting _ _ foo) -> oversimplify foo
|
||||||
(T_DollarSingleQuoted _ s) -> [s]
|
(T_DollarSingleQuoted _ s) -> [s]
|
||||||
@@ -188,6 +189,7 @@ getLiteralStringExt more = g
|
|||||||
g (TA_Expansion _ l) = allInList l
|
g (TA_Expansion _ l) = allInList l
|
||||||
g (T_SingleQuoted _ s) = return s
|
g (T_SingleQuoted _ s) = return s
|
||||||
g (T_Literal _ s) = return s
|
g (T_Literal _ s) = return s
|
||||||
|
g (T_ParamSubSpecialChar _ s) = return s
|
||||||
g x = more x
|
g x = more x
|
||||||
|
|
||||||
-- Is this token a string literal?
|
-- Is this token a string literal?
|
||||||
|
@@ -1015,8 +1015,7 @@ readDollarBracedLiteral = do
|
|||||||
|
|
||||||
readParamSubSpecialChar = do
|
readParamSubSpecialChar = do
|
||||||
id <- getNextId
|
id <- getNextId
|
||||||
many1 paramSubSpecialChars
|
T_ParamSubSpecialChar id <$> many1 paramSubSpecialChars
|
||||||
return $ T_ParamSubSpecialChar id
|
|
||||||
|
|
||||||
prop_readProcSub1 = isOk readProcSub "<(echo test | wc -l)"
|
prop_readProcSub1 = isOk readProcSub "<(echo test | wc -l)"
|
||||||
prop_readProcSub2 = isOk readProcSub "<( if true; then true; fi )"
|
prop_readProcSub2 = isOk readProcSub "<( if true; then true; fi )"
|
||||||
|
Reference in New Issue
Block a user