Merge pull request #1898 from josephcsible/nameexpansion

Simplify nameExpansion
This commit is contained in:
Vidar Holen 2020-04-11 16:18:54 -07:00 committed by GitHub
commit f8c1ffb0dc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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