Simplify getCommandNameAndToken

This commit is contained in:
Joseph C. Sible 2020-04-05 19:01:56 -04:00
parent 01f4423465
commit 8f105074fe
1 changed files with 5 additions and 7 deletions

View File

@ -317,13 +317,11 @@ getCommandNameAndToken :: Token -> (Maybe String, Token)
getCommandNameAndToken t = fromMaybe (Nothing, t) $ do
(T_SimpleCommand _ _ (w:rest)) <- getCommand t
s <- getLiteralString w
if "busybox" `isSuffixOf` s || "builtin" == s
then
case rest of
(applet:_) -> return (getLiteralString applet, applet)
_ -> return (Just s, w)
else
return (Just s, w)
return $ case rest of
(applet:_) | "busybox" `isSuffixOf` s || "builtin" == s ->
(getLiteralString applet, applet)
_ ->
(Just s, w)
-- If a command substitution is a single command, get its name.