mirror of
https://github.com/koalaman/shellcheck
synced 2025-07-14 00:53:15 -07:00
Make command-specific checks act on builtin ...
Now if shellchecks encounters a command like `builtin cmd ...` it applies the same check that would be applied to `cmd ...`.
This commit is contained in:
parent
0e0de94045
commit
84ca7711c4
1 changed files with 5 additions and 1 deletions
|
@ -105,12 +105,16 @@ buildCommandMap = foldl' addCheck Map.empty
|
||||||
|
|
||||||
|
|
||||||
checkCommand :: Map.Map CommandName (Token -> Analysis) -> Token -> Analysis
|
checkCommand :: Map.Map CommandName (Token -> Analysis) -> Token -> Analysis
|
||||||
checkCommand map t@(T_SimpleCommand id _ (cmd:rest)) = fromMaybe (return ()) $ do
|
checkCommand map t@(T_SimpleCommand id cmdPrefix (cmd:rest)) = fromMaybe (return ()) $ do
|
||||||
name <- getLiteralString cmd
|
name <- getLiteralString cmd
|
||||||
return $
|
return $
|
||||||
if '/' `elem` name
|
if '/' `elem` name
|
||||||
then
|
then
|
||||||
Map.findWithDefault nullCheck (Basename $ basename name) map t
|
Map.findWithDefault nullCheck (Basename $ basename name) map t
|
||||||
|
else if name == "builtin" && not (null rest) then
|
||||||
|
let t' = T_SimpleCommand id cmdPrefix rest
|
||||||
|
selectedBuiltin = fromMaybe "" $ getLiteralString . head $ rest
|
||||||
|
in Map.findWithDefault nullCheck (Exactly selectedBuiltin) map t'
|
||||||
else do
|
else do
|
||||||
Map.findWithDefault nullCheck (Exactly name) map t
|
Map.findWithDefault nullCheck (Exactly name) map t
|
||||||
Map.findWithDefault nullCheck (Basename name) map t
|
Map.findWithDefault nullCheck (Basename name) map t
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue