mirror of
https://github.com/koalaman/shellcheck
synced 2025-07-08 05:51:09 -07:00
Rewrite getopts style option parser
This commit is contained in:
parent
8d99926554
commit
f100c2939e
4 changed files with 120 additions and 32 deletions
|
@ -678,13 +678,13 @@ getModifiedVariableCommand base@(T_SimpleCommand id cmdPrefix (T_NormalWord _ (T
|
|||
where
|
||||
parseArgs :: Maybe (Token, Token, String, DataType)
|
||||
parseArgs = do
|
||||
args <- getGnuOpts "d:n:O:s:u:C:c:t" base
|
||||
args <- getGnuOpts "d:n:O:s:u:C:c:t" rest
|
||||
let names = map snd $ filter (\(x,y) -> null x) args
|
||||
if null names
|
||||
then
|
||||
return (base, base, "MAPFILE", DataArray SourceExternal)
|
||||
else do
|
||||
first <- listToMaybe names
|
||||
(_, first) <- listToMaybe names
|
||||
name <- getLiteralString first
|
||||
guard $ isVariableName name
|
||||
return (base, first, name, DataArray SourceExternal)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue