shelly 1.6.8.3 → 1.6.8.4
raw patch · 8 files changed
+36/−5 lines, 8 filesdep ~timePVP: minor bump suggested
API additions: PVP suggests at least a minor version bump
Dependency ranges changed: time
API changes (from Hackage documentation)
+ Shelly: followSymlink :: Bool -> Sh a -> Sh a
+ Shelly.Lifted: followSymlink :: MonadShControl m => Bool -> m a -> m a
+ Shelly.Pipe: followSymlink :: Bool -> Sh a -> Sh a
Files
- README.md +1/−1
- shelly.cabal +3/−3
- src/Shelly.hs +11/−0
- src/Shelly/Base.hs +1/−0
- src/Shelly/Find.hs +2/−1
- src/Shelly/Lifted.hs +4/−0
- src/Shelly/Pipe.hs +4/−0
- test/src/FindSpec.hs +10/−0
README.md view
@@ -47,7 +47,7 @@ ## Alternatives -### Haskell shell scripting libarires+### Haskell shell scripting libraries * [HSH](http://hackage.haskell.org/package/HSH) - A good alternative if you want to mixup usage of String and ByteString rather than just use Text.
shelly.cabal view
@@ -1,6 +1,6 @@ Name: shelly -Version: 1.6.8.3+Version: 1.6.8.4 Synopsis: shell-like (systems) programming in Haskell Description: Shelly provides convenient systems programming in Haskell,@@ -48,7 +48,7 @@ Build-depends: containers >= 0.4.2.0,- time >= 1.3 && < 1.7,+ time >= 1.3 && < 1.9, directory >= 1.1.0.0 && < 1.4.0.0, mtl >= 2, process >= 1.0,@@ -128,7 +128,7 @@ unix-compat < 0.5, system-filepath >= 0.4.7 && < 0.5, system-fileio < 0.4,- time >= 1.3 && < 1.7,+ time >= 1.3 && < 1.9, mtl >= 2, HUnit >= 1.2, hspec >= 1.5,
src/Shelly.hs view
@@ -89,6 +89,7 @@ -- * find functions , find, findWhen, findFold, findDirFilter, findDirFilterWhen, findFoldDirFilter+ , followSymlink ) where import Shelly.Base@@ -911,6 +912,15 @@ modify $ \st -> st { sErrExit = shouldExit } action +-- | 'find'-command follows symbolic links. Defaults to @False@.+-- When @True@, follow symbolic links.+-- When @False@, never follow symbolic links.+followSymlink :: Bool -> Sh a -> Sh a+followSymlink enableFollowSymlink action = sub $ do+ modify $ \st -> st { sFollowSymlink = enableFollowSymlink }+ action++ defReadOnlyState :: ReadOnlyState defReadOnlyState = ReadOnlyState { rosFailToDir = False } @@ -954,6 +964,7 @@ , sPathExecutables = Nothing , sErrExit = True , sReadOnly = ros+ , sFollowSymlink = False } stref <- liftIO $ newIORef def let caught =
src/Shelly/Base.hs view
@@ -127,6 +127,7 @@ , sTrace :: Text -- ^ the trace of command execution , sErrExit :: Bool -- ^ should we exit immediately on any error , sReadOnly :: ReadOnlyState+ , sFollowSymlink :: Bool -- ^ 'find'-command follows symlinks. } data StdHandle = InHandle StdStream
src/Shelly/Find.hs view
@@ -69,7 +69,8 @@ isDir <- liftIO $ isDirectory absolutePath sym <- liftIO $ fmap isSymbolicLink $ getSymbolicLinkStatus (encodeString absolutePath) newAcc <- folder acc relativePath- if isDir && not sym+ follow <- fmap sFollowSymlink get+ if isDir && (follow || not sym) then findFoldDirFilter folder newAcc dirFilter relativePath else return newAcc
src/Shelly/Lifted.hs view
@@ -93,6 +93,7 @@ -- * find functions , S.find, S.findWhen, S.findFold, S.findDirFilter, S.findDirFilterWhen, S.findFoldDirFilter+ , followSymlink ) where import qualified Shelly as S@@ -344,6 +345,9 @@ errExit :: MonadShControl m => Bool -> m a -> m a errExit shouldExit action = controlSh $ \runInSh -> S.errExit shouldExit (runInSh action)++followSymlink :: MonadShControl m => Bool -> m a -> m a+followSymlink enableFollowSymlink action = controlSh $ \runInSh -> S.followSymlink enableFollowSymlink (runInSh action) (-|-) :: (MonadShControl m, MonadSh m) => m Text -> m b -> m b one -|- two = controlSh $ \runInSh -> do
src/Shelly/Pipe.hs view
@@ -92,6 +92,7 @@ -- * find functions , find, findWhen, findFold , findDirFilter, findDirFilterWhen, findFoldDirFilter+ , followSymlink ) where import Prelude hiding (FilePath)@@ -262,6 +263,9 @@ errExit :: Bool -> Sh a -> Sh a errExit b = lift1 (S.errExit b) +-- | see 'S.followSymlink'+followSymlink :: Bool -> Sh a -> Sh a+followSymlink b = lift1 (S.followSymlink b) -- | see 'S.run' run :: FilePath -> [Text] -> Sh Text
test/src/FindSpec.hs view
@@ -67,3 +67,13 @@ "ReadFileSpec.hs", "RmSpec.hs", "RunSpec.hs", "TestInit.hs", "TestMain.hs", "WhichSpec.hs", "WriteSpec.hs", "sleep.hs"]++ it "follow symlinks" $ do+ res <- shelly $ followSymlink True $ relPath "test/data" >>= find >>= mapM (relativeTo "test/data")+ sort res @?= ["dir","nonascii.txt","symlinked_dir","zshrc","dir/symlinked_dir",+ "dir/symlinked_dir/hoge_file","symlinked_dir/hoge_file"]++ it "not follow symlinks" $ do+ res <- shelly $ followSymlink False $ relPath "test/data" >>= find >>= mapM (relativeTo "test/data")+ sort res @?= ["dir","nonascii.txt","symlinked_dir","zshrc","dir/symlinked_dir",+ "symlinked_dir/hoge_file"]