shelly 1.6.3.4 → 1.6.4
raw patch · 3 files changed
+34/−11 lines, 3 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- Shelly: errInit :: StdInit -> HandleInitializer
- Shelly: inInit :: StdInit -> HandleInitializer
- Shelly: instance [incoherent] (CmdArg arg, ShellCmd result) => ShellCmd ([arg] -> result)
- Shelly: instance [incoherent] (CmdArg arg, ShellCmd result) => ShellCmd (arg -> result)
- Shelly: instance [incoherent] (s ~ Text, Show s) => ShellCmd (Sh s)
- Shelly: instance [incoherent] CmdArg FilePath
- Shelly: instance [incoherent] CmdArg String
- Shelly: instance [incoherent] CmdArg Text
- Shelly: instance [incoherent] Exception QuietExit
- Shelly: instance [incoherent] Exception RunFailed
- Shelly: instance [incoherent] Exception e => Exception (ReThrownException e)
- Shelly: instance [incoherent] Exception e => Show (ReThrownException e)
- Shelly: instance [incoherent] ShellCmd (Sh ())
- Shelly: instance [incoherent] ShellCmd (Sh Text)
- Shelly: instance [incoherent] Show QuietExit
- Shelly: instance [incoherent] Show RunFailed
- Shelly: instance [incoherent] ToFilePath FilePath
- Shelly: instance [incoherent] ToFilePath String
- Shelly: instance [incoherent] ToFilePath Text
- Shelly: instance [incoherent] Typeable QuietExit
- Shelly: instance [incoherent] Typeable ReThrownException
- Shelly: instance [incoherent] Typeable RunFailed
- Shelly: outInit :: StdInit -> HandleInitializer
- Shelly.Lifted: instance [incoherent] (Error e, MonadSh m) => MonadSh (ErrorT e m)
- Shelly.Lifted: instance [incoherent] (MonadSh m, s ~ Text, Show s) => ShellCmd (m s)
- Shelly.Lifted: instance [incoherent] (MonadShControl m, Error e) => MonadShControl (ErrorT e m)
- Shelly.Lifted: instance [incoherent] (MonadShControl m, Monoid w) => MonadShControl (RWST r w s m)
- Shelly.Lifted: instance [incoherent] (MonadShControl m, Monoid w) => MonadShControl (WriterT w m)
- Shelly.Lifted: instance [incoherent] (Monoid w, MonadSh m) => MonadSh (RWST r w s m)
- Shelly.Lifted: instance [incoherent] (Monoid w, MonadSh m) => MonadSh (WriterT w m)
- Shelly.Lifted: instance [incoherent] MonadSh Sh
- Shelly.Lifted: instance [incoherent] MonadSh m => MonadSh (ContT r m)
- Shelly.Lifted: instance [incoherent] MonadSh m => MonadSh (IdentityT m)
- Shelly.Lifted: instance [incoherent] MonadSh m => MonadSh (ListT m)
- Shelly.Lifted: instance [incoherent] MonadSh m => MonadSh (MaybeT m)
- Shelly.Lifted: instance [incoherent] MonadSh m => MonadSh (ReaderT r m)
- Shelly.Lifted: instance [incoherent] MonadSh m => MonadSh (StateT s m)
- Shelly.Lifted: instance [incoherent] MonadSh m => ShellCmd (m ())
- Shelly.Lifted: instance [incoherent] MonadSh m => ShellCmd (m Text)
- Shelly.Lifted: instance [incoherent] MonadShControl Sh
- Shelly.Lifted: instance [incoherent] MonadShControl m => MonadShControl (IdentityT m)
- Shelly.Lifted: instance [incoherent] MonadShControl m => MonadShControl (ListT m)
- Shelly.Lifted: instance [incoherent] MonadShControl m => MonadShControl (MaybeT m)
- Shelly.Lifted: instance [incoherent] MonadShControl m => MonadShControl (ReaderT r m)
- Shelly.Lifted: instance [incoherent] MonadShControl m => MonadShControl (StateT s m)
- Shelly.Pipe: instance (ShellArg arg, ShellCommand result) => ShellCommand (arg -> result)
- Shelly.Pipe: instance (s ~ Text, Show s) => ShellCommand (Sh s)
- Shelly.Pipe: instance Alternative Sh
- Shelly.Pipe: instance Applicative Sh
- Shelly.Pipe: instance Functor Sh
- Shelly.Pipe: instance Monad Sh
- Shelly.Pipe: instance MonadIO Sh
- Shelly.Pipe: instance MonadPlus Sh
- Shelly.Pipe: instance ShellArg FilePath
- Shelly.Pipe: instance ShellArg Text
- Shelly.Pipe: instance ShellCommand (Sh ())
- Shelly.Pipe: instance ShellCommand (Sh Text)
+ Shelly: [errInit] :: StdInit -> HandleInitializer
+ Shelly: [inInit] :: StdInit -> HandleInitializer
+ Shelly: [outInit] :: StdInit -> HandleInitializer
+ Shelly: bashPipeFail :: (FilePath -> [Text] -> Sh a) -> FilePath -> [Text] -> Sh a
+ Shelly: instance (Shelly.CmdArg arg, Shelly.ShellCmd result) => Shelly.ShellCmd ([arg] -> result)
+ Shelly: instance (Shelly.CmdArg arg, Shelly.ShellCmd result) => Shelly.ShellCmd (arg -> result)
+ Shelly: instance (s ~ Data.Text.Internal.Text, GHC.Show.Show s) => Shelly.ShellCmd (Shelly.Base.Sh s)
+ Shelly: instance GHC.Exception.Exception Shelly.QuietExit
+ Shelly: instance GHC.Exception.Exception Shelly.RunFailed
+ Shelly: instance GHC.Exception.Exception e => GHC.Exception.Exception (Shelly.ReThrownException e)
+ Shelly: instance GHC.Exception.Exception e => GHC.Show.Show (Shelly.ReThrownException e)
+ Shelly: instance GHC.Show.Show Shelly.QuietExit
+ Shelly: instance GHC.Show.Show Shelly.RunFailed
+ Shelly: instance Shelly.CmdArg Data.Text.Internal.Text
+ Shelly: instance Shelly.CmdArg Filesystem.Path.Internal.FilePath
+ Shelly: instance Shelly.CmdArg GHC.Base.String
+ Shelly: instance Shelly.ShellCmd (Shelly.Base.Sh ())
+ Shelly: instance Shelly.ShellCmd (Shelly.Base.Sh Data.Text.Internal.Text)
+ Shelly: instance Shelly.ToFilePath Data.Text.Internal.Text
+ Shelly: instance Shelly.ToFilePath Filesystem.Path.Internal.FilePath
+ Shelly: instance Shelly.ToFilePath GHC.Base.String
+ Shelly.Lifted: instance (Control.Monad.Trans.Error.Error e, Shelly.Lifted.MonadSh m) => Shelly.Lifted.MonadSh (Control.Monad.Trans.Error.ErrorT e m)
+ Shelly.Lifted: instance (GHC.Base.Monoid w, Shelly.Lifted.MonadSh m) => Shelly.Lifted.MonadSh (Control.Monad.Trans.RWS.Lazy.RWST r w s m)
+ Shelly.Lifted: instance (GHC.Base.Monoid w, Shelly.Lifted.MonadSh m) => Shelly.Lifted.MonadSh (Control.Monad.Trans.RWS.Strict.RWST r w s m)
+ Shelly.Lifted: instance (GHC.Base.Monoid w, Shelly.Lifted.MonadSh m) => Shelly.Lifted.MonadSh (Control.Monad.Trans.Writer.Lazy.WriterT w m)
+ Shelly.Lifted: instance (GHC.Base.Monoid w, Shelly.Lifted.MonadSh m) => Shelly.Lifted.MonadSh (Control.Monad.Trans.Writer.Strict.WriterT w m)
+ Shelly.Lifted: instance (Shelly.Lifted.MonadSh m, s ~ Data.Text.Internal.Text, GHC.Show.Show s) => Shelly.ShellCmd (m s)
+ Shelly.Lifted: instance (Shelly.Lifted.MonadShControl m, Control.Monad.Trans.Error.Error e) => Shelly.Lifted.MonadShControl (Control.Monad.Trans.Error.ErrorT e m)
+ Shelly.Lifted: instance (Shelly.Lifted.MonadShControl m, GHC.Base.Monoid w) => Shelly.Lifted.MonadShControl (Control.Monad.Trans.RWS.Lazy.RWST r w s m)
+ Shelly.Lifted: instance (Shelly.Lifted.MonadShControl m, GHC.Base.Monoid w) => Shelly.Lifted.MonadShControl (Control.Monad.Trans.RWS.Strict.RWST r w s m)
+ Shelly.Lifted: instance (Shelly.Lifted.MonadShControl m, GHC.Base.Monoid w) => Shelly.Lifted.MonadShControl (Control.Monad.Trans.Writer.Lazy.WriterT w m)
+ Shelly.Lifted: instance (Shelly.Lifted.MonadShControl m, GHC.Base.Monoid w) => Shelly.Lifted.MonadShControl (Control.Monad.Trans.Writer.Strict.WriterT w m)
+ Shelly.Lifted: instance Shelly.Lifted.MonadSh Shelly.Base.Sh
+ Shelly.Lifted: instance Shelly.Lifted.MonadSh m => Shelly.Lifted.MonadSh (Control.Monad.Trans.Cont.ContT r m)
+ Shelly.Lifted: instance Shelly.Lifted.MonadSh m => Shelly.Lifted.MonadSh (Control.Monad.Trans.Identity.IdentityT m)
+ Shelly.Lifted: instance Shelly.Lifted.MonadSh m => Shelly.Lifted.MonadSh (Control.Monad.Trans.List.ListT m)
+ Shelly.Lifted: instance Shelly.Lifted.MonadSh m => Shelly.Lifted.MonadSh (Control.Monad.Trans.Maybe.MaybeT m)
+ Shelly.Lifted: instance Shelly.Lifted.MonadSh m => Shelly.Lifted.MonadSh (Control.Monad.Trans.Reader.ReaderT r m)
+ Shelly.Lifted: instance Shelly.Lifted.MonadSh m => Shelly.Lifted.MonadSh (Control.Monad.Trans.State.Lazy.StateT s m)
+ Shelly.Lifted: instance Shelly.Lifted.MonadSh m => Shelly.Lifted.MonadSh (Control.Monad.Trans.State.Strict.StateT s m)
+ Shelly.Lifted: instance Shelly.Lifted.MonadSh m => Shelly.ShellCmd (m ())
+ Shelly.Lifted: instance Shelly.Lifted.MonadSh m => Shelly.ShellCmd (m Data.Text.Internal.Text)
+ Shelly.Lifted: instance Shelly.Lifted.MonadShControl Shelly.Base.Sh
+ Shelly.Lifted: instance Shelly.Lifted.MonadShControl m => Shelly.Lifted.MonadShControl (Control.Monad.Trans.Identity.IdentityT m)
+ Shelly.Lifted: instance Shelly.Lifted.MonadShControl m => Shelly.Lifted.MonadShControl (Control.Monad.Trans.List.ListT m)
+ Shelly.Lifted: instance Shelly.Lifted.MonadShControl m => Shelly.Lifted.MonadShControl (Control.Monad.Trans.Maybe.MaybeT m)
+ Shelly.Lifted: instance Shelly.Lifted.MonadShControl m => Shelly.Lifted.MonadShControl (Control.Monad.Trans.Reader.ReaderT r m)
+ Shelly.Lifted: instance Shelly.Lifted.MonadShControl m => Shelly.Lifted.MonadShControl (Control.Monad.Trans.State.Lazy.StateT s m)
+ Shelly.Lifted: instance Shelly.Lifted.MonadShControl m => Shelly.Lifted.MonadShControl (Control.Monad.Trans.State.Strict.StateT s m)
+ Shelly.Pipe: instance (Shelly.Pipe.ShellArg arg, Shelly.Pipe.ShellCommand result) => Shelly.Pipe.ShellCommand (arg -> result)
+ Shelly.Pipe: instance (s ~ Data.Text.Internal.Text, GHC.Show.Show s) => Shelly.Pipe.ShellCommand (Shelly.Pipe.Sh s)
+ Shelly.Pipe: instance Control.Monad.IO.Class.MonadIO Shelly.Pipe.Sh
+ Shelly.Pipe: instance GHC.Base.Alternative Shelly.Pipe.Sh
+ Shelly.Pipe: instance GHC.Base.Applicative Shelly.Pipe.Sh
+ Shelly.Pipe: instance GHC.Base.Functor Shelly.Pipe.Sh
+ Shelly.Pipe: instance GHC.Base.Monad Shelly.Pipe.Sh
+ Shelly.Pipe: instance GHC.Base.MonadPlus Shelly.Pipe.Sh
+ Shelly.Pipe: instance Shelly.Pipe.ShellArg Data.Text.Internal.Text
+ Shelly.Pipe: instance Shelly.Pipe.ShellArg Filesystem.Path.Internal.FilePath
+ Shelly.Pipe: instance Shelly.Pipe.ShellCommand (Shelly.Pipe.Sh ())
+ Shelly.Pipe: instance Shelly.Pipe.ShellCommand (Shelly.Pipe.Sh Data.Text.Internal.Text)
- Shelly: (<.>) :: ToFilePath filepath => filepath -> Text -> FilePath
+ Shelly: (<.>) :: (ToFilePath filepath) => filepath -> Text -> FilePath
- Shelly: catch_sh :: Exception e => Sh a -> (e -> Sh a) -> Sh a
+ Shelly: catch_sh :: (Exception e) => Sh a -> (e -> Sh a) -> Sh a
- Shelly: cmd :: ShellCmd result => FilePath -> result
+ Shelly: cmd :: (ShellCmd result) => FilePath -> result
- Shelly: handle_sh :: Exception e => (e -> Sh a) -> Sh a -> Sh a
+ Shelly: handle_sh :: (Exception e) => (e -> Sh a) -> Sh a -> Sh a
- Shelly: inspect :: Show s => s -> Sh ()
+ Shelly: inspect :: (Show s) => s -> Sh ()
- Shelly: inspect_err :: Show s => s -> Sh ()
+ Shelly: inspect_err :: (Show s) => s -> Sh ()
- Shelly: unless :: Monad m => Bool -> m () -> m ()
+ Shelly: unless :: Applicative f => Bool -> f () -> f ()
- Shelly: when :: Monad m => Bool -> m () -> m ()
+ Shelly: when :: Applicative f => Bool -> f () -> f ()
- Shelly.Lifted: (<.>) :: ToFilePath filepath => filepath -> Text -> FilePath
+ Shelly.Lifted: (<.>) :: (ToFilePath filepath) => filepath -> Text -> FilePath
- Shelly.Lifted: catch_sh :: Exception e => Sh a -> (e -> Sh a) -> Sh a
+ Shelly.Lifted: catch_sh :: (Exception e) => Sh a -> (e -> Sh a) -> Sh a
- Shelly.Lifted: cmd :: ShellCmd result => FilePath -> result
+ Shelly.Lifted: cmd :: (ShellCmd result) => FilePath -> result
- Shelly.Lifted: handle_sh :: Exception e => (e -> Sh a) -> Sh a -> Sh a
+ Shelly.Lifted: handle_sh :: (Exception e) => (e -> Sh a) -> Sh a -> Sh a
- Shelly.Lifted: unless :: Monad m => Bool -> m () -> m ()
+ Shelly.Lifted: unless :: Applicative f => Bool -> f () -> f ()
- Shelly.Lifted: when :: Monad m => Bool -> m () -> m ()
+ Shelly.Lifted: when :: Applicative f => Bool -> f () -> f ()
- Shelly.Pipe: (<.>) :: ToFilePath filepath => filepath -> Text -> FilePath
+ Shelly.Pipe: (<.>) :: (ToFilePath filepath) => filepath -> Text -> FilePath
- Shelly.Pipe: catch_sh :: Exception e => Sh a -> (e -> Sh a) -> Sh a
+ Shelly.Pipe: catch_sh :: (Exception e) => Sh a -> (e -> Sh a) -> Sh a
- Shelly.Pipe: cmd :: ShellCommand result => FilePath -> result
+ Shelly.Pipe: cmd :: (ShellCommand result) => FilePath -> result
- Shelly.Pipe: unless :: Monad m => Bool -> m () -> m ()
+ Shelly.Pipe: unless :: Applicative f => Bool -> f () -> f ()
- Shelly.Pipe: when :: Monad m => Bool -> m () -> m ()
+ Shelly.Pipe: when :: Applicative f => Bool -> f () -> f ()
Files
- shelly.cabal +20/−1
- src/Shelly.hs +10/−9
- test/src/RunSpec.hs +4/−1
shelly.cabal view
@@ -1,6 +1,6 @@ Name: shelly -Version: 1.6.3.4+Version: 1.6.4 Synopsis: shell-like (systems) programming in Haskell Description: Shelly provides convenient systems programming in Haskell,@@ -88,6 +88,25 @@ type: exitcode-stdio-1.0 hs-source-dirs: src test/src main-is: TestMain.hs+ other-modules:+ CopySpec+ EnvSpec+ FailureSpec+ FindSpec+ Help+ LiftedSpec+ MoveSpec+ ReadFileSpec+ RmSpec+ RunSpec+ Shelly+ Shelly.Base+ Shelly.Find+ Shelly.Lifted+ TestInit+ WhichSpec+ WriteSpec+ ghc-options: -O2 -Wall -fwarn-tabs -funbox-strict-fields -threaded -fno-warn-unused-do-bind -fno-warn-type-defaults
src/Shelly.hs view
@@ -30,7 +30,8 @@ , log_stdout_with, log_stderr_with -- * Running external commands.- , run, run_, bash, bash_, runFoldLines, cmd, FoldCallback+ , run, run_, runFoldLines, cmd, FoldCallback+ , bash, bash_, bashPipeFail , (-|-), lastStderr, setStdin, lastExitCode , command, command_, command1, command1_ , sshPairs, sshPairs_@@ -1067,8 +1068,7 @@ run :: FilePath -> [Text] -> Sh Text run fp args = return . lineSeqToText =<< runFoldLines mempty (|>) fp args --- | Like `run`, but it invokes the user-requested program with _bash_,--- setting _pipefail_ appropriately.+-- | Like `run`, but it invokes the user-requested program with _bash_. bash :: FilePath -> [Text] -> Sh Text bash fp args = escaping False $ run "bash" $ bashArgs fp args @@ -1076,14 +1076,15 @@ bash_ fp args = escaping False $ run_ "bash" $ bashArgs fp args bashArgs :: FilePath -> [Text] -> [Text]-bashArgs fp args =- -- trapping PIPE is needed to avoid random failures from setting pipefail- --- -- https://github.com/yesodweb/Shelly.hs/issues/106- -- http://stackoverflow.com/questions/22464786/ignoring-bash-pipefail-for-error-code-141- ["-c", "'set -o pipefail; trap '' PIPE; " <> sanitise (toTextIgnore fp : args) <> "'"]+bashArgs fp args = ["-c", "'" <> sanitise (toTextIgnore fp : args) <> "'"] where sanitise = T.replace "'" "\'" . T.intercalate " "++-- | Use this with `bash` to set _pipefail_+--+-- > bashPipeFail $ bash "echo foo | echo"+bashPipeFail :: (FilePath -> [Text] -> Sh a) -> FilePath -> [Text] -> Sh a+bashPipeFail runner fp args = runner "set -o pipefail;" (toTextIgnore fp : args) -- | bind some arguments to run for re-use. Example: --
test/src/RunSpec.hs view
@@ -40,11 +40,14 @@ $ bash "cat" [ "test/data/nonascii.txt" ] res @?= "Selbstverst\228ndlich \252berraschend\n" + {- This throws spurious errors on some systems it "can detect failing commands in pipes" $ do eCode <- shelly $ escaping False $ errExit False $ do- bash_ "echo" [ "'foo'", "|", "ls", "\"eoueouoe\"", "2>/dev/null", "|", "echo", "'bar'" ]+ bashPipeFail+ bash_ "echo" ["'foo'", "|", "ls", "\"eoueouoe\"", "2>/dev/null", "|", "echo", "'bar'" ] lastExitCode eCode `shouldSatisfy` (/= 0)+ -} it "preserve pipe behaviour" $ do (eCode, res) <- shelly $ escaping False $ errExit False $ do