Language.Sh.Expansion
Description
This is the expansion module. It provides an interface for a monad in which expansions can happen, and then defines the expansions.
- data ExpansionFunctions m = ExpansionFunctions {}
- noGlobExpansion :: Monad m => Word -> m [String]
- expand :: (Monad m, Functor m) => ExpansionFunctions m -> [Word] -> m [String]
- expandWord :: (Monad m, Functor m) => ExpansionFunctions m -> Word -> m String
- expandPattern :: (Monad m, Functor m) => ExpansionFunctions m -> Word -> m Word
Documentation
data ExpansionFunctions m Source
Constructors
ExpansionFunctions | |
noGlobExpansion :: Monad m => Word -> m [String]Source
This is a default function that basically treats globs as literals.
expand :: (Monad m, Functor m) => ExpansionFunctions m -> [Word] -> m [String]Source
We have one main sticking point here... in the case of A=*
, we want
to use expandWord, and do the glob expansion. In the case of >*
, we
want to try the glob expansion and then given an error in the case
that we get multiple hits. We could make one more expansion function?
(expandNoAmbiguousGlob?)
expandWord :: (Monad m, Functor m) => ExpansionFunctions m -> Word -> m StringSource
Test: A=1 * --> A=1 ... -> so it's getting expand'ed/joined, and not expandWord'ed. For now, we'll leave globs out of this function, but it seems like maybe the only use is in redirects, so then we can make this the one that doesn't allow ambiguity. Also, we know that glob expansion comes after field splitting... (B= ; A=2$B*) Tricky: A=3$B*; echo $A --> looks silly, but echo $A...
expandPattern :: (Monad m, Functor m) => ExpansionFunctions m -> Word -> m WordSource
This is a version of expandWord that doesn't deal with globs or remove quotes! It's currently only used in case statements.