Simplify nameExpansion

This commit is contained in:
Joseph C. Sible 2020-04-05 14:04:23 -04:00
parent f7547c9a5a
commit d2fa88dd91
1 changed files with 3 additions and 4 deletions

View File

@ -840,10 +840,9 @@ getBracedReference s = fromMaybe s $
if c `elem` "*@#?-$!" then return [c] else fail "not special"
getSpecial _ = fail "empty"
nameExpansion ('!':rest) = do -- e.g. ${!foo*bar*}
let suffix = dropWhile isVariableChar rest
guard $ suffix /= rest -- e.g. ${!@}
first <- suffix !!! 0
nameExpansion ('!':next:rest) = do -- e.g. ${!foo*bar*}
guard $ isVariableChar next -- e.g. ${!@}
first <- find (not . isVariableChar) rest
guard $ first `elem` "*?"
return ""
nameExpansion _ = Nothing