Merge pull request #99 from rpglover64/master

`sed` now errors if passed a pattern matching the empty string
This commit is contained in:
Gabriel Gonzalez 2015-08-22 12:35:34 -07:00
commit b7ccdc6f23

View file

@ -958,11 +958,15 @@ grep pattern s = do
-}
sed :: Pattern Text -> Shell Text -> Shell Text
sed pattern s = do
when (matchesEmpty pattern) (die message)
let pattern' = fmap Text.concat
(many (pattern <|> fmap Text.singleton anyChar))
txt <- s
txt':_ <- return (match pattern' txt)
return txt'
where
message = "sed: the given pattern matches the empty string"
matchesEmpty = not . null . flip match ""
-- | Search a directory recursively for all files matching the given `Pattern`
find :: Pattern a -> FilePath -> Shell FilePath