shellwords 0.1.0.0 → 0.1.1.0
raw patch · 2 files changed
+20/−26 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- shellwords.cabal +2/−2
- src/ShellWords.hs +18/−24
shellwords.cabal view
@@ -2,10 +2,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: 11e7209deb6877bc69c75f56eba1279ab472ce405ad7cf1d1f576f059cb05126+-- hash: 2e963e67460e2f0c8a0eaacb4cd50df10ec08b0ade7f08593d3858ca6d8ce1a8 name: shellwords-version: 0.1.0.0+version: 0.1.1.0 synopsis: Parse strings into words, like a shell would description: See https://github.com/pbrisbin/hs-shellwords#readme category: Text
src/ShellWords.hs view
@@ -4,9 +4,9 @@ ( parse ) where ---import Control.Monad (void) import Data.Bifunctor (first) import Data.Char+import Data.Maybe (fromMaybe) import Data.Semigroup ((<>)) import Data.Text (Text) import Data.Text as T@@ -24,12 +24,7 @@ parser = shellword `sepBy` space1 shellword :: Parser Text-shellword = choice- [ quoted- , try quotedFlag -- N.B. may fail after consuming "--"- , flagArgument- , value- ]+shellword = choice [quoted, shelloption, value] -- | A balanced, single- or double-quoted string quoted :: Parser Text@@ -37,26 +32,25 @@ q <- oneOf ['\'', '\"'] T.pack <$> manyTill (try (escaped q) <|> anyToken) (char q) --- | This wierd case: @--\"foo bar\"@-quotedFlag :: Parser Text-quotedFlag = (<>)- <$> flagPrefix- <*> quoted+-- | A flag, with or without an argument+shelloption :: Parser Text+shelloption = (<>)+ <$> flag+ <*> (fromMaybe "" <$> optional argument) --- | A flag and (possibly quoted) argument, @--foo=\"bar\"@-flagArgument :: Parser Text-flagArgument = concat4- <$> flagPrefix- <*> (T.pack <$> manyTill anyToken (char '='))- <*> pure "="- <*> (quoted <|> value)- where- concat4 a b c d = a <> b <> c <> d+-- | A flag like @--foo@, or (apparently) @--\"baz bat\"@+flag :: Parser Text+flag = (<>)+ <$> (string "--" <|> string "-")+ <*> (quoted <|> (T.pack <$> many (noneOf ['=', ' ']))) -flagPrefix :: Parser Text-flagPrefix = string "--" <|> string "-"+-- | The argument to a flag like @=foo@, or @=\"baz bat\"@+argument :: Parser Text+argument = (<>)+ <$> (T.singleton <$> char '=')+ <*> (quoted <|> value) --- | A bare value, here till an (unescaped) space+-- | A plain value, here till an (unescaped) space value :: Parser Text value = T.pack <$> many (try (escaped ' ') <|> nonSpace)