Merge pull request #99 from rpglover64/master
`sed` now errors if passed a pattern matching the empty string
This commit is contained in:
commit
b7ccdc6f23
1 changed files with 4 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue