From da98f7eee8aa0efe03dd78c59772cbb256319f9a Mon Sep 17 00:00:00 2001 From: Index Int Date: Thu, 13 Aug 2015 16:25:18 +0300 Subject: [PATCH 1/2] Update README.md to use Stack fixes #93 --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 0f5cb8a..b699110 100644 --- a/README.md +++ b/README.md @@ -6,14 +6,14 @@ as `coreutils` embedded within the Haskell language. ## Quick start -* Install the [Haskell Platform](http://www.haskell.org/platform/) +* Install [Stack](https://github.com/commercialhaskell/stack) -* `cabal install turtle` +* `stack setup && stack install turtle` Then fire up `ghci`: ``` -$ ghci +$ stack ghci Prelude> :set -XOverloadedStrings Prelude> import Turtle ``` @@ -44,7 +44,7 @@ FilePath "/usr/lib/libgif.so.4.1" ... ``` -To learn more, read the [turtle tutorial](http://hackage.haskell.org/package/turtle-1.0.2/docs/Turtle-Tutorial.html). +To learn more, read the [turtle tutorial](https://hackage.haskell.org/package/turtle-1.2.1/docs/Turtle-Tutorial.html). ## Goals From e02fae1f75612a8de5b6d5c23995c1c045ee07a7 Mon Sep 17 00:00:00 2001 From: Alex Rozenshteyn Date: Tue, 18 Aug 2015 14:55:55 -0400 Subject: [PATCH 2/2] Use `matchesEmpty` predicate in `sed` --- src/Turtle/Prelude.hs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Turtle/Prelude.hs b/src/Turtle/Prelude.hs index 26f3b76..514a768 100644 --- a/src/Turtle/Prelude.hs +++ b/src/Turtle/Prelude.hs @@ -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