Getting command name from busybox now gets applet name
This commit is contained in:
parent
46fb91b44d
commit
35c74e4747
ShellCheck
|
@ -240,8 +240,15 @@ getCommand t =
|
||||||
|
|
||||||
-- Maybe get the command name of a token representing a command
|
-- Maybe get the command name of a token representing a command
|
||||||
getCommandName t = do
|
getCommandName t = do
|
||||||
(T_SimpleCommand _ _ (w:_)) <- getCommand t
|
(T_SimpleCommand _ _ (w:rest)) <- getCommand t
|
||||||
getLiteralString w
|
s <- getLiteralString w
|
||||||
|
if "busybox" `isSuffixOf` s
|
||||||
|
then
|
||||||
|
case rest of
|
||||||
|
(applet:_) -> getLiteralString applet
|
||||||
|
_ -> return s
|
||||||
|
else
|
||||||
|
return s
|
||||||
|
|
||||||
-- If a command substitution is a single command, get its name.
|
-- If a command substitution is a single command, get its name.
|
||||||
-- $(date +%s) = Just "date"
|
-- $(date +%s) = Just "date"
|
||||||
|
|
|
@ -745,9 +745,9 @@ checkStderrRedirect params redir@(T_Redirecting _ [
|
||||||
usesOutput t =
|
usesOutput t =
|
||||||
case t of
|
case t of
|
||||||
(T_Pipeline _ _ list) -> length list > 1 && not (isParentOf (parentMap params) (last list) redir)
|
(T_Pipeline _ _ list) -> length list > 1 && not (isParentOf (parentMap params) (last list) redir)
|
||||||
(T_ProcSub {}) -> True
|
T_ProcSub {} -> True
|
||||||
(T_DollarExpansion {}) -> True
|
T_DollarExpansion {} -> True
|
||||||
(T_Backticked {}) -> True
|
T_Backticked {} -> True
|
||||||
_ -> False
|
_ -> False
|
||||||
isCaptured = any usesOutput $ getPath (parentMap params) redir
|
isCaptured = any usesOutput $ getPath (parentMap params) redir
|
||||||
|
|
||||||
|
@ -776,6 +776,7 @@ prop_checkSingleQuotedVariables9 = verifyNot checkSingleQuotedVariables "find .
|
||||||
prop_checkSingleQuotedVariables10= verify checkSingleQuotedVariables "echo '`pwd`'"
|
prop_checkSingleQuotedVariables10= verify checkSingleQuotedVariables "echo '`pwd`'"
|
||||||
prop_checkSingleQuotedVariables11= verifyNot checkSingleQuotedVariables "sed '${/lol/d}'"
|
prop_checkSingleQuotedVariables11= verifyNot checkSingleQuotedVariables "sed '${/lol/d}'"
|
||||||
prop_checkSingleQuotedVariables12= verifyNot checkSingleQuotedVariables "eval 'echo $1'"
|
prop_checkSingleQuotedVariables12= verifyNot checkSingleQuotedVariables "eval 'echo $1'"
|
||||||
|
prop_checkSingleQuotedVariables13= verifyNot checkSingleQuotedVariables "busybox awk '{print $1}'"
|
||||||
checkSingleQuotedVariables params t@(T_SingleQuoted id s) =
|
checkSingleQuotedVariables params t@(T_SingleQuoted id s) =
|
||||||
when (s `matches` re) $
|
when (s `matches` re) $
|
||||||
if "sed" == commandName
|
if "sed" == commandName
|
||||||
|
@ -813,7 +814,7 @@ checkSingleQuotedVariables params t@(T_SingleQuoted id s) =
|
||||||
isOkAssignment t =
|
isOkAssignment t =
|
||||||
case t of
|
case t of
|
||||||
T_Assignment _ _ name _ _ -> name `elem` commonlyQuoted
|
T_Assignment _ _ name _ _ -> name `elem` commonlyQuoted
|
||||||
otherwise -> False
|
_ -> False
|
||||||
|
|
||||||
re = mkRegex "\\$[{(0-9a-zA-Z_]|`.*`"
|
re = mkRegex "\\$[{(0-9a-zA-Z_]|`.*`"
|
||||||
sedContra = mkRegex "\\$[{dpsaic]($|[^a-zA-Z])"
|
sedContra = mkRegex "\\$[{dpsaic]($|[^a-zA-Z])"
|
||||||
|
|
Loading…
Reference in New Issue