{-# LANGUAGE FlexibleInstances, TypeSynonymInstances,
TypeFamilies, ExistentialQuantification #-}
module Shelly.Pipe
(
Sh, shs, shelly, shellyFailDir, shsFailDir, sub, silently, verbosely, escaping, print_stdout, print_commands, tracing, errExit, log_stdout_with, log_stderr_with
, roll, unroll, liftSh
, FoldCallback
, run, run_, runFoldLines, cmd
, (-|-), lastStderr, setStdin, lastExitCode
, command, command_, command1, command1_
, sshPairs, sshPairs_
, setenv, get_env, get_env_text, get_env_def, appendToPath, prependToPath
, cd, chdir, pwd
, echo, echo_n, echo_err, echo_n_err, inspect, inspect_err
, tag, trace, show_command
, ls, lsT, test_e, test_f, test_d, test_s, which
, absPath, (</>), (<.>), canonic, canonicalize, relPath, relativeTo
, hasExt
, mv, rm, rm_f, rm_rf, cp, cp_r, mkdir, mkdir_p, mkdirTree
, readfile, readBinary, writefile, appendfile, touchfile, withTmpDir
, exit, errorExit, quietExit, terror
, catchany, catch_sh, finally_sh
, ShellyHandler(..), catches_sh
, catchany_sh
, toTextIgnore, toTextWarn, S.fromText
, (<$>), whenM, unlessM, time
, liftIO, when, unless, FilePath
, get, put
, find, findWhen, findFold
, findDirFilter, findDirFilterWhen, findFoldDirFilter
, followSymlink
) where
import qualified Shelly as S
import Shelly
( (</>), (<.>), hasExt
, whenM, unlessM, toTextIgnore
, catchany
, FoldCallback
)
import Shelly.Base (State)
import Control.Applicative
import Control.Monad
import Control.Monad.Trans
import Control.Exception
import Data.Maybe ( fromMaybe )
import Data.ByteString ( ByteString )
import Data.Tree ( Tree )
import Data.Text as T hiding (concat, all, find, cons)
newtype Sh a = Sh { forall a. Sh a -> Sh [a]
unSh :: S.Sh [a] }
instance Functor Sh where
fmap :: forall a b. (a -> b) -> Sh a -> Sh b
fmap a -> b
f = Sh [b] -> Sh b
forall a. Sh [a] -> Sh a
Sh (Sh [b] -> Sh b) -> (Sh a -> Sh [b]) -> Sh a -> Sh b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ([a] -> [b]) -> Sh [a] -> Sh [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
f) (Sh [a] -> Sh [b]) -> (Sh a -> Sh [a]) -> Sh a -> Sh [b]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Sh a -> Sh [a]
forall a. Sh a -> Sh [a]
unSh
instance Applicative Sh where
pure :: forall a. a -> Sh a
pure = Sh [a] -> Sh a
forall a. Sh [a] -> Sh a
Sh (Sh [a] -> Sh a) -> (a -> Sh [a]) -> a -> Sh a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [a] -> Sh [a]
forall (f :: * -> *) a. Applicative f => a -> f a
pure ([a] -> Sh [a]) -> (a -> [a]) -> a -> Sh [a]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> [a]
forall (f :: * -> *) a. Applicative f => a -> f a
pure
<*> :: forall a b. Sh (a -> b) -> Sh a -> Sh b
(<*>) = Sh (a -> b) -> Sh a -> Sh b
forall (m :: * -> *) a b. Monad m => m (a -> b) -> m a -> m b
ap
Sh a
a *> :: forall a b. Sh a -> Sh b -> Sh b
*> Sh b
b = Sh [b] -> Sh b
forall a. Sh [a] -> Sh a
Sh (Sh [b] -> Sh b) -> Sh [b] -> Sh b
forall a b. (a -> b) -> a -> b
$ Sh a -> Sh [a]
forall a. Sh a -> Sh [a]
unSh Sh a
a Sh [a] -> Sh [b] -> Sh [b]
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Sh b -> Sh [b]
forall a. Sh a -> Sh [a]
unSh Sh b
b
instance Monad Sh where
return :: forall a. a -> Sh a
return = a -> Sh a
forall (f :: * -> *) a. Applicative f => a -> f a
pure
Sh a
a >>= :: forall a b. Sh a -> (a -> Sh b) -> Sh b
>>= a -> Sh b
f = Sh [b] -> Sh b
forall a. Sh [a] -> Sh a
Sh (Sh [b] -> Sh b) -> Sh [b] -> Sh b
forall a b. (a -> b) -> a -> b
$ ([[b]] -> [b]) -> Sh [[b]] -> Sh [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap [[b]] -> [b]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat (Sh [[b]] -> Sh [b]) -> Sh [[b]] -> Sh [b]
forall a b. (a -> b) -> a -> b
$ (a -> Sh [b]) -> [a] -> Sh [[b]]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM (Sh b -> Sh [b]
forall a. Sh a -> Sh [a]
unSh (Sh b -> Sh [b]) -> (a -> Sh b) -> a -> Sh [b]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Sh b
f) ([a] -> Sh [[b]]) -> Sh [a] -> Sh [[b]]
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< Sh a -> Sh [a]
forall a. Sh a -> Sh [a]
unSh Sh a
a
>> :: forall a b. Sh a -> Sh b -> Sh b
(>>) = Sh a -> Sh b -> Sh b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
(*>)
instance Alternative Sh where
empty :: forall a. Sh a
empty = Sh a
forall (m :: * -> *) a. MonadPlus m => m a
mzero
<|> :: forall a. Sh a -> Sh a -> Sh a
(<|>) = Sh a -> Sh a -> Sh a
forall (m :: * -> *) a. MonadPlus m => m a -> m a -> m a
mplus
instance MonadPlus Sh where
mzero :: forall a. Sh a
mzero = Sh [a] -> Sh a
forall a. Sh [a] -> Sh a
Sh (Sh [a] -> Sh a) -> Sh [a] -> Sh a
forall a b. (a -> b) -> a -> b
$ [a] -> Sh [a]
forall (m :: * -> *) a. Monad m => a -> m a
return []
mplus :: forall a. Sh a -> Sh a -> Sh a
mplus Sh a
a Sh a
b = Sh [a] -> Sh a
forall a. Sh [a] -> Sh a
Sh (Sh [a] -> Sh a) -> Sh [a] -> Sh a
forall a b. (a -> b) -> a -> b
$ ([a] -> [a] -> [a]) -> Sh [a] -> Sh [a] -> Sh [a]
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 [a] -> [a] -> [a]
forall a. [a] -> [a] -> [a]
(++) (Sh a -> Sh [a]
forall a. Sh a -> Sh [a]
unSh Sh a
a) (Sh a -> Sh [a]
forall a. Sh a -> Sh [a]
unSh Sh a
b)
instance MonadIO Sh where
liftIO :: forall a. IO a -> Sh a
liftIO = (IO a -> Sh a) -> IO a -> Sh a
forall a b. (a -> Sh b) -> a -> Sh b
sh1 IO a -> Sh a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO
sh0 :: S.Sh a -> Sh a
sh0 :: forall a. Sh a -> Sh a
sh0 = Sh [a] -> Sh a
forall a. Sh [a] -> Sh a
Sh (Sh [a] -> Sh a) -> (Sh a -> Sh [a]) -> Sh a -> Sh a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> [a]) -> Sh a -> Sh [a]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> [a]
forall (m :: * -> *) a. Monad m => a -> m a
return
sh1 :: (a -> S.Sh b) -> (a -> Sh b)
sh1 :: forall a b. (a -> Sh b) -> a -> Sh b
sh1 a -> Sh b
f = \a
a -> Sh b -> Sh b
forall a. Sh a -> Sh a
sh0 (a -> Sh b
f a
a)
sh2 :: (a1 -> a2 -> S.Sh b) -> (a1 -> a2 -> Sh b)
sh2 :: forall a1 a2 b. (a1 -> a2 -> Sh b) -> a1 -> a2 -> Sh b
sh2 a1 -> a2 -> Sh b
f = \a1
a a2
b -> Sh b -> Sh b
forall a. Sh a -> Sh a
sh0 (a1 -> a2 -> Sh b
f a1
a a2
b)
sh3 :: (a1 -> a2 -> a3 -> S.Sh b) -> (a1 -> a2 -> a3 -> Sh b)
sh3 :: forall a1 a2 a3 b.
(a1 -> a2 -> a3 -> Sh b) -> a1 -> a2 -> a3 -> Sh b
sh3 a1 -> a2 -> a3 -> Sh b
f = \a1
a a2
b a3
c -> Sh b -> Sh b
forall a. Sh a -> Sh a
sh0 (a1 -> a2 -> a3 -> Sh b
f a1
a a2
b a3
c)
sh4 :: (a1 -> a2 -> a3 -> a4 -> S.Sh b) -> (a1 -> a2 -> a3 -> a4 -> Sh b)
sh4 :: forall a1 a2 a3 a4 b.
(a1 -> a2 -> a3 -> a4 -> Sh b) -> a1 -> a2 -> a3 -> a4 -> Sh b
sh4 a1 -> a2 -> a3 -> a4 -> Sh b
f = \a1
a a2
b a3
c a4
d -> Sh b -> Sh b
forall a. Sh a -> Sh a
sh0 (a1 -> a2 -> a3 -> a4 -> Sh b
f a1
a a2
b a3
c a4
d)
sh0s :: S.Sh [a] -> Sh a
sh0s :: forall a. Sh [a] -> Sh a
sh0s = Sh [a] -> Sh a
forall a. Sh [a] -> Sh a
Sh
sh1s :: (a -> S.Sh [b]) -> (a -> Sh b)
sh1s :: forall a b. (a -> Sh [b]) -> a -> Sh b
sh1s a -> Sh [b]
f = \a
a -> Sh [b] -> Sh b
forall a. Sh [a] -> Sh a
sh0s (a -> Sh [b]
f a
a)
lift1 :: (S.Sh a -> S.Sh b) -> (Sh a -> Sh b)
lift1 :: forall a b. (Sh a -> Sh b) -> Sh a -> Sh b
lift1 Sh a -> Sh b
f = Sh [b] -> Sh b
forall a. Sh [a] -> Sh a
Sh (Sh [b] -> Sh b) -> (Sh a -> Sh [b]) -> Sh a -> Sh b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((a -> Sh b) -> [a] -> Sh [b]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM (Sh a -> Sh b
f (Sh a -> Sh b) -> (a -> Sh a) -> a -> Sh b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Sh a
forall (m :: * -> *) a. Monad m => a -> m a
return) ([a] -> Sh [b]) -> Sh [a] -> Sh [b]
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< ) (Sh [a] -> Sh [b]) -> (Sh a -> Sh [a]) -> Sh a -> Sh [b]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Sh a -> Sh [a]
forall a. Sh a -> Sh [a]
unSh
lift2 :: (S.Sh a -> S.Sh b -> S.Sh c) -> (Sh a -> Sh b -> Sh c)
lift2 :: forall a b c. (Sh a -> Sh b -> Sh c) -> Sh a -> Sh b -> Sh c
lift2 Sh a -> Sh b -> Sh c
f Sh a
a Sh b
b = Sh [c] -> Sh c
forall a. Sh [a] -> Sh a
Sh (Sh [c] -> Sh c) -> Sh [c] -> Sh c
forall a b. (a -> b) -> a -> b
$ Sh (Sh [c]) -> Sh [c]
forall (m :: * -> *) a. Monad m => m (m a) -> m a
join (Sh (Sh [c]) -> Sh [c]) -> Sh (Sh [c]) -> Sh [c]
forall a b. (a -> b) -> a -> b
$ ([a] -> [b] -> Sh [c]) -> Sh [a] -> Sh [b] -> Sh (Sh [c])
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 ((a -> b -> Sh c) -> [a] -> [b] -> Sh [c]
forall (m :: * -> *) a b c.
Monad m =>
(a -> b -> m c) -> [a] -> [b] -> m [c]
mapM2 a -> b -> Sh c
f') (Sh a -> Sh [a]
forall a. Sh a -> Sh [a]
unSh Sh a
a) (Sh b -> Sh [b]
forall a. Sh a -> Sh [a]
unSh Sh b
b)
where f' :: a -> b -> Sh c
f' = \a
x b
y -> Sh a -> Sh b -> Sh c
f (a -> Sh a
forall (m :: * -> *) a. Monad m => a -> m a
return a
x) (b -> Sh b
forall (m :: * -> *) a. Monad m => a -> m a
return b
y)
mapM2 :: Monad m => (a -> b -> m c)-> [a] -> [b] -> m [c]
mapM2 :: forall (m :: * -> *) a b c.
Monad m =>
(a -> b -> m c) -> [a] -> [b] -> m [c]
mapM2 a -> b -> m c
f [a]
as [b]
bs = [m c] -> m [c]
forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
sequence ([m c] -> m [c]) -> [m c] -> m [c]
forall a b. (a -> b) -> a -> b
$ (a -> b -> m c) -> [a] -> [b] -> [m c]
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 a -> b -> m c
f [a]
as [b]
bs
unroll :: Sh a -> Sh [a]
unroll :: forall a. Sh a -> Sh [a]
unroll = Sh [[a]] -> Sh [a]
forall a. Sh [a] -> Sh a
Sh (Sh [[a]] -> Sh [a]) -> (Sh a -> Sh [[a]]) -> Sh a -> Sh [a]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ([a] -> [[a]]) -> Sh [a] -> Sh [[a]]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap [a] -> [[a]]
forall (m :: * -> *) a. Monad m => a -> m a
return (Sh [a] -> Sh [[a]]) -> (Sh a -> Sh [a]) -> Sh a -> Sh [[a]]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Sh a -> Sh [a]
forall a. Sh a -> Sh [a]
unSh
roll :: Sh [a] -> Sh a
roll :: forall a. Sh [a] -> Sh a
roll = Sh [a] -> Sh a
forall a. Sh [a] -> Sh a
Sh (Sh [a] -> Sh a) -> (Sh [a] -> Sh [a]) -> Sh [a] -> Sh a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ([[a]] -> [a]) -> Sh [[a]] -> Sh [a]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap [[a]] -> [a]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat (Sh [[a]] -> Sh [a]) -> (Sh [a] -> Sh [[a]]) -> Sh [a] -> Sh [a]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Sh [a] -> Sh [[a]]
forall a. Sh a -> Sh [a]
unSh
liftSh :: ([a] -> [b]) -> Sh a -> Sh b
liftSh :: forall a b. ([a] -> [b]) -> Sh a -> Sh b
liftSh [a] -> [b]
f = Sh [b] -> Sh b
forall a. Sh [a] -> Sh a
Sh (Sh [b] -> Sh b) -> (Sh a -> Sh [b]) -> Sh a -> Sh b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ([a] -> [b]) -> Sh [a] -> Sh [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap [a] -> [b]
f (Sh [a] -> Sh [b]) -> (Sh a -> Sh [a]) -> Sh a -> Sh [b]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Sh a -> Sh [a]
forall a. Sh a -> Sh [a]
unSh
shelly :: MonadIO m => Sh a -> m [a]
shelly :: forall (m :: * -> *) a. MonadIO m => Sh a -> m [a]
shelly = Sh [a] -> m [a]
forall (m :: * -> *) a. MonadIO m => Sh a -> m a
S.shelly (Sh [a] -> m [a]) -> (Sh a -> Sh [a]) -> Sh a -> m [a]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Sh a -> Sh [a]
forall a. Sh a -> Sh [a]
unSh
shs :: MonadIO m => Sh () -> m ()
shs :: forall (m :: * -> *). MonadIO m => Sh () -> m ()
shs Sh ()
x = Sh () -> m [()]
forall (m :: * -> *) a. MonadIO m => Sh a -> m [a]
shelly Sh ()
x m [()] -> m () -> m ()
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> () -> m ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
shellyFailDir :: MonadIO m => Sh a -> m [a]
shellyFailDir :: forall (m :: * -> *) a. MonadIO m => Sh a -> m [a]
shellyFailDir = Sh [a] -> m [a]
forall (m :: * -> *) a. MonadIO m => Sh a -> m a
S.shellyFailDir (Sh [a] -> m [a]) -> (Sh a -> Sh [a]) -> Sh a -> m [a]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Sh a -> Sh [a]
forall a. Sh a -> Sh [a]
unSh
shsFailDir :: MonadIO m => Sh () -> m ()
shsFailDir :: forall (m :: * -> *). MonadIO m => Sh () -> m ()
shsFailDir Sh ()
x = Sh () -> m [()]
forall (m :: * -> *) a. MonadIO m => Sh a -> m [a]
shellyFailDir Sh ()
x m [()] -> m () -> m ()
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> () -> m ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
sub :: Sh a -> Sh a
sub :: forall a. Sh a -> Sh a
sub = (Sh a -> Sh a) -> Sh a -> Sh a
forall a b. (Sh a -> Sh b) -> Sh a -> Sh b
lift1 Sh a -> Sh a
forall a. Sh a -> Sh a
S.sub
silently :: Sh a -> Sh a
silently :: forall a. Sh a -> Sh a
silently = (Sh a -> Sh a) -> Sh a -> Sh a
forall a b. (Sh a -> Sh b) -> Sh a -> Sh b
lift1 Sh a -> Sh a
forall a. Sh a -> Sh a
S.silently
verbosely :: Sh a -> Sh a
verbosely :: forall a. Sh a -> Sh a
verbosely = (Sh a -> Sh a) -> Sh a -> Sh a
forall a b. (Sh a -> Sh b) -> Sh a -> Sh b
lift1 Sh a -> Sh a
forall a. Sh a -> Sh a
S.verbosely
escaping :: Bool -> Sh a -> Sh a
escaping :: forall a. Bool -> Sh a -> Sh a
escaping Bool
b = (Sh a -> Sh a) -> Sh a -> Sh a
forall a b. (Sh a -> Sh b) -> Sh a -> Sh b
lift1 (Bool -> Sh a -> Sh a
forall a. Bool -> Sh a -> Sh a
S.escaping Bool
b)
log_stdout_with :: (Text -> IO ()) -> Sh a -> Sh a
log_stdout_with :: forall a. (Text -> IO ()) -> Sh a -> Sh a
log_stdout_with Text -> IO ()
logger = (Sh a -> Sh a) -> Sh a -> Sh a
forall a b. (Sh a -> Sh b) -> Sh a -> Sh b
lift1 ((Text -> IO ()) -> Sh a -> Sh a
forall a. (Text -> IO ()) -> Sh a -> Sh a
S.log_stdout_with Text -> IO ()
logger)
log_stderr_with :: (Text -> IO ()) -> Sh a -> Sh a
log_stderr_with :: forall a. (Text -> IO ()) -> Sh a -> Sh a
log_stderr_with Text -> IO ()
logger = (Sh a -> Sh a) -> Sh a -> Sh a
forall a b. (Sh a -> Sh b) -> Sh a -> Sh b
lift1 ((Text -> IO ()) -> Sh a -> Sh a
forall a. (Text -> IO ()) -> Sh a -> Sh a
S.log_stdout_with Text -> IO ()
logger)
print_stdout :: Bool -> Sh a -> Sh a
print_stdout :: forall a. Bool -> Sh a -> Sh a
print_stdout Bool
b = (Sh a -> Sh a) -> Sh a -> Sh a
forall a b. (Sh a -> Sh b) -> Sh a -> Sh b
lift1 (Bool -> Sh a -> Sh a
forall a. Bool -> Sh a -> Sh a
S.print_stdout Bool
b)
print_commands :: Bool -> Sh a -> Sh a
print_commands :: forall a. Bool -> Sh a -> Sh a
print_commands Bool
b = (Sh a -> Sh a) -> Sh a -> Sh a
forall a b. (Sh a -> Sh b) -> Sh a -> Sh b
lift1 (Bool -> Sh a -> Sh a
forall a. Bool -> Sh a -> Sh a
S.print_commands Bool
b)
tracing :: Bool -> Sh a -> Sh a
tracing :: forall a. Bool -> Sh a -> Sh a
tracing Bool
b = (Sh a -> Sh a) -> Sh a -> Sh a
forall a b. (Sh a -> Sh b) -> Sh a -> Sh b
lift1 (Bool -> Sh a -> Sh a
forall a. Bool -> Sh a -> Sh a
S.tracing Bool
b)
errExit :: Bool -> Sh a -> Sh a
errExit :: forall a. Bool -> Sh a -> Sh a
errExit Bool
b = (Sh a -> Sh a) -> Sh a -> Sh a
forall a b. (Sh a -> Sh b) -> Sh a -> Sh b
lift1 (Bool -> Sh a -> Sh a
forall a. Bool -> Sh a -> Sh a
S.errExit Bool
b)
followSymlink :: Bool -> Sh a -> Sh a
followSymlink :: forall a. Bool -> Sh a -> Sh a
followSymlink Bool
b = (Sh a -> Sh a) -> Sh a -> Sh a
forall a b. (Sh a -> Sh b) -> Sh a -> Sh b
lift1 (Bool -> Sh a -> Sh a
forall a. Bool -> Sh a -> Sh a
S.followSymlink Bool
b)
run :: FilePath -> [Text] -> Sh Text
run :: FilePath -> [Text] -> Sh Text
run FilePath
a [Text]
b = Sh Text -> Sh Text
forall a. Sh a -> Sh a
sh0 (Sh Text -> Sh Text) -> Sh Text -> Sh Text
forall a b. (a -> b) -> a -> b
$ FilePath -> [Text] -> Sh Text
S.run FilePath
a [Text]
b
run_ :: FilePath -> [Text] -> Sh ()
run_ :: FilePath -> [Text] -> Sh ()
run_ FilePath
a [Text]
b = Sh () -> Sh ()
forall a. Sh a -> Sh a
sh0 (Sh () -> Sh ()) -> Sh () -> Sh ()
forall a b. (a -> b) -> a -> b
$ FilePath -> [Text] -> Sh ()
S.run_ FilePath
a [Text]
b
runFoldLines :: a -> FoldCallback a -> FilePath -> [Text] -> Sh a
runFoldLines :: forall a. a -> FoldCallback a -> FilePath -> [Text] -> Sh a
runFoldLines a
a FoldCallback a
cb FilePath
fp [Text]
ts = Sh a -> Sh a
forall a. Sh a -> Sh a
sh0 (Sh a -> Sh a) -> Sh a -> Sh a
forall a b. (a -> b) -> a -> b
$ a -> FoldCallback a -> FilePath -> [Text] -> Sh a
forall a. a -> FoldCallback a -> FilePath -> [Text] -> Sh a
S.runFoldLines a
a FoldCallback a
cb FilePath
fp [Text]
ts
(-|-) :: Sh Text -> Sh b -> Sh b
-|- :: forall b. Sh Text -> Sh b -> Sh b
(-|-) = (Sh Text -> Sh b -> Sh b) -> Sh Text -> Sh b -> Sh b
forall a b c. (Sh a -> Sh b -> Sh c) -> Sh a -> Sh b -> Sh c
lift2 Sh Text -> Sh b -> Sh b
forall b. Sh Text -> Sh b -> Sh b
(S.-|-)
lastStderr :: Sh Text
lastStderr :: Sh Text
lastStderr = Sh Text -> Sh Text
forall a. Sh a -> Sh a
sh0 Sh Text
S.lastStderr
setStdin :: Text -> Sh ()
setStdin :: Text -> Sh ()
setStdin = (Text -> Sh ()) -> Text -> Sh ()
forall a b. (a -> Sh b) -> a -> Sh b
sh1 Text -> Sh ()
S.setStdin
lastExitCode :: Sh Int
lastExitCode :: Sh Int
lastExitCode = Sh Int -> Sh Int
forall a. Sh a -> Sh a
sh0 Sh Int
S.lastExitCode
command :: FilePath -> [Text] -> [Text] -> Sh Text
command :: FilePath -> [Text] -> [Text] -> Sh Text
command = (FilePath -> [Text] -> [Text] -> Sh Text)
-> FilePath -> [Text] -> [Text] -> Sh Text
forall a1 a2 a3 b.
(a1 -> a2 -> a3 -> Sh b) -> a1 -> a2 -> a3 -> Sh b
sh3 FilePath -> [Text] -> [Text] -> Sh Text
S.command
command_ :: FilePath -> [Text] -> [Text] -> Sh ()
command_ :: FilePath -> [Text] -> [Text] -> Sh ()
command_ = (FilePath -> [Text] -> [Text] -> Sh ())
-> FilePath -> [Text] -> [Text] -> Sh ()
forall a1 a2 a3 b.
(a1 -> a2 -> a3 -> Sh b) -> a1 -> a2 -> a3 -> Sh b
sh3 FilePath -> [Text] -> [Text] -> Sh ()
S.command_
command1 :: FilePath -> [Text] -> Text -> [Text] -> Sh Text
command1 :: FilePath -> [Text] -> Text -> [Text] -> Sh Text
command1 = (FilePath -> [Text] -> Text -> [Text] -> Sh Text)
-> FilePath -> [Text] -> Text -> [Text] -> Sh Text
forall a1 a2 a3 a4 b.
(a1 -> a2 -> a3 -> a4 -> Sh b) -> a1 -> a2 -> a3 -> a4 -> Sh b
sh4 FilePath -> [Text] -> Text -> [Text] -> Sh Text
S.command1
command1_ :: FilePath -> [Text] -> Text -> [Text] -> Sh ()
command1_ :: FilePath -> [Text] -> Text -> [Text] -> Sh ()
command1_ = (FilePath -> [Text] -> Text -> [Text] -> Sh ())
-> FilePath -> [Text] -> Text -> [Text] -> Sh ()
forall a1 a2 a3 a4 b.
(a1 -> a2 -> a3 -> a4 -> Sh b) -> a1 -> a2 -> a3 -> a4 -> Sh b
sh4 FilePath -> [Text] -> Text -> [Text] -> Sh ()
S.command1_
sshPairs :: Text -> [(FilePath, [Text])] -> Sh Text
sshPairs :: Text -> [(FilePath, [Text])] -> Sh Text
sshPairs = (Text -> [(FilePath, [Text])] -> Sh Text)
-> Text -> [(FilePath, [Text])] -> Sh Text
forall a1 a2 b. (a1 -> a2 -> Sh b) -> a1 -> a2 -> Sh b
sh2 Text -> [(FilePath, [Text])] -> Sh Text
S.sshPairs
sshPairs_ :: Text -> [(FilePath, [Text])] -> Sh ()
sshPairs_ :: Text -> [(FilePath, [Text])] -> Sh ()
sshPairs_ = (Text -> [(FilePath, [Text])] -> Sh ())
-> Text -> [(FilePath, [Text])] -> Sh ()
forall a1 a2 b. (a1 -> a2 -> Sh b) -> a1 -> a2 -> Sh b
sh2 Text -> [(FilePath, [Text])] -> Sh ()
S.sshPairs_
setenv :: Text -> Text -> Sh ()
setenv :: Text -> Text -> Sh ()
setenv = (Text -> Text -> Sh ()) -> Text -> Text -> Sh ()
forall a1 a2 b. (a1 -> a2 -> Sh b) -> a1 -> a2 -> Sh b
sh2 Text -> Text -> Sh ()
S.setenv
get_env :: Text -> Sh (Maybe Text)
get_env :: Text -> Sh (Maybe Text)
get_env = (Text -> Sh (Maybe Text)) -> Text -> Sh (Maybe Text)
forall a b. (a -> Sh b) -> a -> Sh b
sh1 Text -> Sh (Maybe Text)
S.get_env
get_env_text :: Text -> Sh Text
get_env_text :: Text -> Sh Text
get_env_text = (Text -> Sh Text) -> Text -> Sh Text
forall a b. (a -> Sh b) -> a -> Sh b
sh1 Text -> Sh Text
S.get_env_text
get_env_def :: Text -> Text -> Sh Text
get_env_def :: Text -> Text -> Sh Text
get_env_def Text
a Text
d = Sh Text -> Sh Text
forall a. Sh a -> Sh a
sh0 (Sh Text -> Sh Text) -> Sh Text -> Sh Text
forall a b. (a -> b) -> a -> b
$ (Maybe Text -> Text) -> Sh (Maybe Text) -> Sh Text
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Text -> Maybe Text -> Text
forall a. a -> Maybe a -> a
fromMaybe Text
d) (Sh (Maybe Text) -> Sh Text) -> Sh (Maybe Text) -> Sh Text
forall a b. (a -> b) -> a -> b
$ Text -> Sh (Maybe Text)
S.get_env Text
a
{-# DEPRECATED get_env_def "use fromMaybe DEFAULT get_env" #-}
appendToPath :: FilePath -> Sh ()
appendToPath :: FilePath -> Sh ()
appendToPath = (FilePath -> Sh ()) -> FilePath -> Sh ()
forall a b. (a -> Sh b) -> a -> Sh b
sh1 FilePath -> Sh ()
S.appendToPath
prependToPath :: FilePath -> Sh ()
prependToPath :: FilePath -> Sh ()
prependToPath = (FilePath -> Sh ()) -> FilePath -> Sh ()
forall a b. (a -> Sh b) -> a -> Sh b
sh1 FilePath -> Sh ()
S.prependToPath
cd :: FilePath -> Sh ()
cd :: FilePath -> Sh ()
cd = (FilePath -> Sh ()) -> FilePath -> Sh ()
forall a b. (a -> Sh b) -> a -> Sh b
sh1 FilePath -> Sh ()
S.cd
chdir :: FilePath -> Sh a -> Sh a
chdir :: forall a. FilePath -> Sh a -> Sh a
chdir FilePath
p = (Sh a -> Sh a) -> Sh a -> Sh a
forall a b. (Sh a -> Sh b) -> Sh a -> Sh b
lift1 (FilePath -> Sh a -> Sh a
forall a. FilePath -> Sh a -> Sh a
S.chdir FilePath
p)
pwd :: Sh FilePath
pwd :: Sh FilePath
pwd = Sh FilePath -> Sh FilePath
forall a. Sh a -> Sh a
sh0 Sh FilePath
S.pwd
echo, echo_n_err, echo_err, echo_n :: Text -> Sh ()
echo :: Text -> Sh ()
echo = (Text -> Sh ()) -> Text -> Sh ()
forall a b. (a -> Sh b) -> a -> Sh b
sh1 Text -> Sh ()
S.echo
echo_n_err :: Text -> Sh ()
echo_n_err = (Text -> Sh ()) -> Text -> Sh ()
forall a b. (a -> Sh b) -> a -> Sh b
sh1 Text -> Sh ()
S.echo_n_err
echo_err :: Text -> Sh ()
echo_err = (Text -> Sh ()) -> Text -> Sh ()
forall a b. (a -> Sh b) -> a -> Sh b
sh1 Text -> Sh ()
S.echo_err
echo_n :: Text -> Sh ()
echo_n = (Text -> Sh ()) -> Text -> Sh ()
forall a b. (a -> Sh b) -> a -> Sh b
sh1 Text -> Sh ()
S.echo_n
inspect :: Show s => s -> Sh ()
inspect :: forall s. Show s => s -> Sh ()
inspect = (s -> Sh ()) -> s -> Sh ()
forall a b. (a -> Sh b) -> a -> Sh b
sh1 s -> Sh ()
forall s. Show s => s -> Sh ()
S.inspect
inspect_err :: Show s => s -> Sh ()
inspect_err :: forall s. Show s => s -> Sh ()
inspect_err = (s -> Sh ()) -> s -> Sh ()
forall a b. (a -> Sh b) -> a -> Sh b
sh1 s -> Sh ()
forall s. Show s => s -> Sh ()
S.inspect_err
tag :: Sh a -> Text -> Sh a
tag :: forall a. Sh a -> Text -> Sh a
tag Sh a
a Text
t = (Sh a -> Sh a) -> Sh a -> Sh a
forall a b. (Sh a -> Sh b) -> Sh a -> Sh b
lift1 ((Sh a -> Text -> Sh a) -> Text -> Sh a -> Sh a
forall a b c. (a -> b -> c) -> b -> a -> c
flip Sh a -> Text -> Sh a
forall a. Sh a -> Text -> Sh a
S.tag Text
t) Sh a
a
trace :: Text -> Sh ()
trace :: Text -> Sh ()
trace = (Text -> Sh ()) -> Text -> Sh ()
forall a b. (a -> Sh b) -> a -> Sh b
sh1 Text -> Sh ()
S.trace
show_command :: FilePath -> [Text] -> Text
show_command :: FilePath -> [Text] -> Text
show_command = FilePath -> [Text] -> Text
S.show_command
ls :: FilePath -> Sh FilePath
ls :: FilePath -> Sh FilePath
ls = (FilePath -> Sh [FilePath]) -> FilePath -> Sh FilePath
forall a b. (a -> Sh [b]) -> a -> Sh b
sh1s FilePath -> Sh [FilePath]
S.ls
lsT :: FilePath -> Sh Text
lsT :: FilePath -> Sh Text
lsT = (FilePath -> Sh [Text]) -> FilePath -> Sh Text
forall a b. (a -> Sh [b]) -> a -> Sh b
sh1s FilePath -> Sh [Text]
S.lsT
test_e :: FilePath -> Sh Bool
test_e :: FilePath -> Sh Bool
test_e = (FilePath -> Sh Bool) -> FilePath -> Sh Bool
forall a b. (a -> Sh b) -> a -> Sh b
sh1 FilePath -> Sh Bool
S.test_e
test_f :: FilePath -> Sh Bool
test_f :: FilePath -> Sh Bool
test_f = (FilePath -> Sh Bool) -> FilePath -> Sh Bool
forall a b. (a -> Sh b) -> a -> Sh b
sh1 FilePath -> Sh Bool
S.test_f
test_d :: FilePath -> Sh Bool
test_d :: FilePath -> Sh Bool
test_d = (FilePath -> Sh Bool) -> FilePath -> Sh Bool
forall a b. (a -> Sh b) -> a -> Sh b
sh1 FilePath -> Sh Bool
S.test_d
test_s :: FilePath -> Sh Bool
test_s :: FilePath -> Sh Bool
test_s = (FilePath -> Sh Bool) -> FilePath -> Sh Bool
forall a b. (a -> Sh b) -> a -> Sh b
sh1 FilePath -> Sh Bool
S.test_s
which :: FilePath -> Sh (Maybe FilePath)
which :: FilePath -> Sh (Maybe FilePath)
which = (FilePath -> Sh (Maybe FilePath))
-> FilePath -> Sh (Maybe FilePath)
forall a b. (a -> Sh b) -> a -> Sh b
sh1 FilePath -> Sh (Maybe FilePath)
S.which
absPath :: FilePath -> Sh FilePath
absPath :: FilePath -> Sh FilePath
absPath = (FilePath -> Sh FilePath) -> FilePath -> Sh FilePath
forall a b. (a -> Sh b) -> a -> Sh b
sh1 FilePath -> Sh FilePath
S.absPath
canonic :: FilePath -> Sh FilePath
canonic :: FilePath -> Sh FilePath
canonic = (FilePath -> Sh FilePath) -> FilePath -> Sh FilePath
forall a b. (a -> Sh b) -> a -> Sh b
sh1 FilePath -> Sh FilePath
S.canonic
canonicalize :: FilePath -> Sh FilePath
canonicalize :: FilePath -> Sh FilePath
canonicalize = (FilePath -> Sh FilePath) -> FilePath -> Sh FilePath
forall a b. (a -> Sh b) -> a -> Sh b
sh1 FilePath -> Sh FilePath
S.canonicalize
relPath :: FilePath -> Sh FilePath
relPath :: FilePath -> Sh FilePath
relPath = (FilePath -> Sh FilePath) -> FilePath -> Sh FilePath
forall a b. (a -> Sh b) -> a -> Sh b
sh1 FilePath -> Sh FilePath
S.relPath
relativeTo :: FilePath
-> FilePath
-> Sh FilePath
relativeTo :: FilePath -> FilePath -> Sh FilePath
relativeTo = (FilePath -> FilePath -> Sh FilePath)
-> FilePath -> FilePath -> Sh FilePath
forall a1 a2 b. (a1 -> a2 -> Sh b) -> a1 -> a2 -> Sh b
sh2 FilePath -> FilePath -> Sh FilePath
S.relativeTo
mv :: FilePath -> FilePath -> Sh ()
mv :: FilePath -> FilePath -> Sh ()
mv = (FilePath -> FilePath -> Sh ()) -> FilePath -> FilePath -> Sh ()
forall a1 a2 b. (a1 -> a2 -> Sh b) -> a1 -> a2 -> Sh b
sh2 FilePath -> FilePath -> Sh ()
S.mv
rm :: FilePath -> Sh ()
rm :: FilePath -> Sh ()
rm = (FilePath -> Sh ()) -> FilePath -> Sh ()
forall a b. (a -> Sh b) -> a -> Sh b
sh1 FilePath -> Sh ()
S.rm
rm_f :: FilePath -> Sh ()
rm_f :: FilePath -> Sh ()
rm_f = (FilePath -> Sh ()) -> FilePath -> Sh ()
forall a b. (a -> Sh b) -> a -> Sh b
sh1 FilePath -> Sh ()
S.rm_f
rm_rf :: FilePath -> Sh ()
rm_rf :: FilePath -> Sh ()
rm_rf = (FilePath -> Sh ()) -> FilePath -> Sh ()
forall a b. (a -> Sh b) -> a -> Sh b
sh1 FilePath -> Sh ()
S.rm_rf
cp :: FilePath -> FilePath -> Sh ()
cp :: FilePath -> FilePath -> Sh ()
cp = (FilePath -> FilePath -> Sh ()) -> FilePath -> FilePath -> Sh ()
forall a1 a2 b. (a1 -> a2 -> Sh b) -> a1 -> a2 -> Sh b
sh2 FilePath -> FilePath -> Sh ()
S.cp
cp_r :: FilePath -> FilePath -> Sh ()
cp_r :: FilePath -> FilePath -> Sh ()
cp_r = (FilePath -> FilePath -> Sh ()) -> FilePath -> FilePath -> Sh ()
forall a1 a2 b. (a1 -> a2 -> Sh b) -> a1 -> a2 -> Sh b
sh2 FilePath -> FilePath -> Sh ()
S.cp_r
mkdir :: FilePath -> Sh ()
mkdir :: FilePath -> Sh ()
mkdir = (FilePath -> Sh ()) -> FilePath -> Sh ()
forall a b. (a -> Sh b) -> a -> Sh b
sh1 FilePath -> Sh ()
S.mkdir
mkdir_p :: FilePath -> Sh ()
mkdir_p :: FilePath -> Sh ()
mkdir_p = (FilePath -> Sh ()) -> FilePath -> Sh ()
forall a b. (a -> Sh b) -> a -> Sh b
sh1 FilePath -> Sh ()
S.mkdir_p
mkdirTree :: Tree FilePath -> Sh ()
mkdirTree :: Tree FilePath -> Sh ()
mkdirTree = (Tree FilePath -> Sh ()) -> Tree FilePath -> Sh ()
forall a b. (a -> Sh b) -> a -> Sh b
sh1 Tree FilePath -> Sh ()
S.mkdirTree
readfile :: FilePath -> Sh Text
readfile :: FilePath -> Sh Text
readfile = (FilePath -> Sh Text) -> FilePath -> Sh Text
forall a b. (a -> Sh b) -> a -> Sh b
sh1 FilePath -> Sh Text
S.readfile
readBinary :: FilePath -> Sh ByteString
readBinary :: FilePath -> Sh ByteString
readBinary = (FilePath -> Sh ByteString) -> FilePath -> Sh ByteString
forall a b. (a -> Sh b) -> a -> Sh b
sh1 FilePath -> Sh ByteString
S.readBinary
writefile :: FilePath -> Text -> Sh ()
writefile :: FilePath -> Text -> Sh ()
writefile = (FilePath -> Text -> Sh ()) -> FilePath -> Text -> Sh ()
forall a1 a2 b. (a1 -> a2 -> Sh b) -> a1 -> a2 -> Sh b
sh2 FilePath -> Text -> Sh ()
S.writefile
touchfile :: FilePath -> Sh ()
touchfile :: FilePath -> Sh ()
touchfile = (FilePath -> Sh ()) -> FilePath -> Sh ()
forall a b. (a -> Sh b) -> a -> Sh b
sh1 FilePath -> Sh ()
S.touchfile
appendfile :: FilePath -> Text -> Sh ()
appendfile :: FilePath -> Text -> Sh ()
appendfile = (FilePath -> Text -> Sh ()) -> FilePath -> Text -> Sh ()
forall a1 a2 b. (a1 -> a2 -> Sh b) -> a1 -> a2 -> Sh b
sh2 FilePath -> Text -> Sh ()
S.appendfile
withTmpDir :: (FilePath -> Sh a) -> Sh a
withTmpDir :: forall a. (FilePath -> Sh a) -> Sh a
withTmpDir FilePath -> Sh a
f = Sh [a] -> Sh a
forall a. Sh [a] -> Sh a
Sh (Sh [a] -> Sh a) -> Sh [a] -> Sh a
forall a b. (a -> b) -> a -> b
$ (FilePath -> Sh [a]) -> Sh [a]
forall a. (FilePath -> Sh a) -> Sh a
S.withTmpDir (Sh a -> Sh [a]
forall a. Sh a -> Sh [a]
unSh (Sh a -> Sh [a]) -> (FilePath -> Sh a) -> FilePath -> Sh [a]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. FilePath -> Sh a
f)
find :: FilePath -> Sh FilePath
find :: FilePath -> Sh FilePath
find = (FilePath -> Sh [FilePath]) -> FilePath -> Sh FilePath
forall a b. (a -> Sh [b]) -> a -> Sh b
sh1s FilePath -> Sh [FilePath]
S.find
findWhen :: (FilePath -> Sh Bool) -> FilePath -> Sh FilePath
findWhen :: (FilePath -> Sh Bool) -> FilePath -> Sh FilePath
findWhen FilePath -> Sh Bool
p FilePath
a = Sh [FilePath] -> Sh FilePath
forall a. Sh [a] -> Sh a
Sh (Sh [FilePath] -> Sh FilePath) -> Sh [FilePath] -> Sh FilePath
forall a b. (a -> b) -> a -> b
$ (FilePath -> Sh Bool) -> FilePath -> Sh [FilePath]
S.findWhen (([Bool] -> Bool) -> Sh [Bool] -> Sh Bool
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap [Bool] -> Bool
forall (t :: * -> *). Foldable t => t Bool -> Bool
and (Sh [Bool] -> Sh Bool)
-> (FilePath -> Sh [Bool]) -> FilePath -> Sh Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Sh Bool -> Sh [Bool]
forall a. Sh a -> Sh [a]
unSh (Sh Bool -> Sh [Bool])
-> (FilePath -> Sh Bool) -> FilePath -> Sh [Bool]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. FilePath -> Sh Bool
p) FilePath
a
findFold :: (a -> FilePath -> Sh a) -> a -> FilePath -> Sh a
findFold :: forall a. (a -> FilePath -> Sh a) -> a -> FilePath -> Sh a
findFold a -> FilePath -> Sh a
cons a
nil FilePath
a = Sh [a] -> Sh a
forall a. Sh [a] -> Sh a
Sh (Sh [a] -> Sh a) -> Sh [a] -> Sh a
forall a b. (a -> b) -> a -> b
$ ([a] -> FilePath -> Sh [a]) -> [a] -> FilePath -> Sh [a]
forall a. (a -> FilePath -> Sh a) -> a -> FilePath -> Sh a
S.findFold [a] -> FilePath -> Sh [a]
cons' [a]
nil' FilePath
a
where nil' :: [a]
nil' = a -> [a]
forall (m :: * -> *) a. Monad m => a -> m a
return a
nil
cons' :: [a] -> FilePath -> Sh [a]
cons' [a]
as FilePath
dir = Sh a -> Sh [a]
forall a. Sh a -> Sh [a]
unSh (Sh a -> Sh [a]) -> Sh a -> Sh [a]
forall a b. (a -> b) -> a -> b
$ Sh [a] -> Sh a
forall a. Sh [a] -> Sh a
roll (Sh [a] -> Sh a) -> Sh [a] -> Sh a
forall a b. (a -> b) -> a -> b
$ (a -> Sh a) -> [a] -> Sh [a]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM ((a -> FilePath -> Sh a) -> FilePath -> a -> Sh a
forall a b c. (a -> b -> c) -> b -> a -> c
flip a -> FilePath -> Sh a
cons FilePath
dir) [a]
as
findDirFilter :: (FilePath -> Sh Bool) -> FilePath -> Sh FilePath
findDirFilter :: (FilePath -> Sh Bool) -> FilePath -> Sh FilePath
findDirFilter FilePath -> Sh Bool
p FilePath
a = Sh [FilePath] -> Sh FilePath
forall a. Sh [a] -> Sh a
Sh (Sh [FilePath] -> Sh FilePath) -> Sh [FilePath] -> Sh FilePath
forall a b. (a -> b) -> a -> b
$ (FilePath -> Sh Bool) -> FilePath -> Sh [FilePath]
S.findDirFilter (([Bool] -> Bool) -> Sh [Bool] -> Sh Bool
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap [Bool] -> Bool
forall (t :: * -> *). Foldable t => t Bool -> Bool
and (Sh [Bool] -> Sh Bool)
-> (FilePath -> Sh [Bool]) -> FilePath -> Sh Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Sh Bool -> Sh [Bool]
forall a. Sh a -> Sh [a]
unSh (Sh Bool -> Sh [Bool])
-> (FilePath -> Sh Bool) -> FilePath -> Sh [Bool]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. FilePath -> Sh Bool
p) FilePath
a
findDirFilterWhen :: (FilePath -> Sh Bool)
-> (FilePath -> Sh Bool)
-> FilePath
-> Sh FilePath
findDirFilterWhen :: (FilePath -> Sh Bool)
-> (FilePath -> Sh Bool) -> FilePath -> Sh FilePath
findDirFilterWhen FilePath -> Sh Bool
dirPred FilePath -> Sh Bool
filePred FilePath
a =
Sh [FilePath] -> Sh FilePath
forall a. Sh [a] -> Sh a
Sh (Sh [FilePath] -> Sh FilePath) -> Sh [FilePath] -> Sh FilePath
forall a b. (a -> b) -> a -> b
$ (FilePath -> Sh Bool)
-> (FilePath -> Sh Bool) -> FilePath -> Sh [FilePath]
S.findDirFilterWhen
(([Bool] -> Bool) -> Sh [Bool] -> Sh Bool
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap [Bool] -> Bool
forall (t :: * -> *). Foldable t => t Bool -> Bool
and (Sh [Bool] -> Sh Bool)
-> (FilePath -> Sh [Bool]) -> FilePath -> Sh Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Sh Bool -> Sh [Bool]
forall a. Sh a -> Sh [a]
unSh (Sh Bool -> Sh [Bool])
-> (FilePath -> Sh Bool) -> FilePath -> Sh [Bool]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. FilePath -> Sh Bool
dirPred)
(([Bool] -> Bool) -> Sh [Bool] -> Sh Bool
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap [Bool] -> Bool
forall (t :: * -> *). Foldable t => t Bool -> Bool
and (Sh [Bool] -> Sh Bool)
-> (FilePath -> Sh [Bool]) -> FilePath -> Sh Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Sh Bool -> Sh [Bool]
forall a. Sh a -> Sh [a]
unSh (Sh Bool -> Sh [Bool])
-> (FilePath -> Sh Bool) -> FilePath -> Sh [Bool]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. FilePath -> Sh Bool
filePred)
FilePath
a
findFoldDirFilter :: (a -> FilePath -> Sh a) -> a -> (FilePath -> Sh Bool) -> FilePath -> Sh a
findFoldDirFilter :: forall a.
(a -> FilePath -> Sh a)
-> a -> (FilePath -> Sh Bool) -> FilePath -> Sh a
findFoldDirFilter a -> FilePath -> Sh a
cons a
nil FilePath -> Sh Bool
p FilePath
a = Sh [a] -> Sh a
forall a. Sh [a] -> Sh a
Sh (Sh [a] -> Sh a) -> Sh [a] -> Sh a
forall a b. (a -> b) -> a -> b
$ ([a] -> FilePath -> Sh [a])
-> [a] -> (FilePath -> Sh Bool) -> FilePath -> Sh [a]
forall a.
(a -> FilePath -> Sh a)
-> a -> (FilePath -> Sh Bool) -> FilePath -> Sh a
S.findFoldDirFilter [a] -> FilePath -> Sh [a]
cons' [a]
nil' FilePath -> Sh Bool
p' FilePath
a
where p' :: FilePath -> Sh Bool
p' = ([Bool] -> Bool) -> Sh [Bool] -> Sh Bool
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap [Bool] -> Bool
forall (t :: * -> *). Foldable t => t Bool -> Bool
and (Sh [Bool] -> Sh Bool)
-> (FilePath -> Sh [Bool]) -> FilePath -> Sh Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Sh Bool -> Sh [Bool]
forall a. Sh a -> Sh [a]
unSh (Sh Bool -> Sh [Bool])
-> (FilePath -> Sh Bool) -> FilePath -> Sh [Bool]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. FilePath -> Sh Bool
p
nil' :: [a]
nil' = a -> [a]
forall (m :: * -> *) a. Monad m => a -> m a
return a
nil
cons' :: [a] -> FilePath -> Sh [a]
cons' [a]
as FilePath
dir = Sh a -> Sh [a]
forall a. Sh a -> Sh [a]
unSh (Sh a -> Sh [a]) -> Sh a -> Sh [a]
forall a b. (a -> b) -> a -> b
$ Sh [a] -> Sh a
forall a. Sh [a] -> Sh a
roll (Sh [a] -> Sh a) -> Sh [a] -> Sh a
forall a b. (a -> b) -> a -> b
$ (a -> Sh a) -> [a] -> Sh [a]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM ((a -> FilePath -> Sh a) -> FilePath -> a -> Sh a
forall a b c. (a -> b -> c) -> b -> a -> c
flip a -> FilePath -> Sh a
cons FilePath
dir) [a]
as
exit :: Int -> Sh ()
exit :: Int -> Sh ()
exit = (Int -> Sh ()) -> Int -> Sh ()
forall a b. (a -> Sh b) -> a -> Sh b
sh1 Int -> Sh ()
forall a. Int -> Sh a
S.exit
errorExit :: Text -> Sh ()
errorExit :: Text -> Sh ()
errorExit = (Text -> Sh ()) -> Text -> Sh ()
forall a b. (a -> Sh b) -> a -> Sh b
sh1 Text -> Sh ()
forall a. Text -> Sh a
S.errorExit
quietExit :: Int -> Sh ()
quietExit :: Int -> Sh ()
quietExit = (Int -> Sh ()) -> Int -> Sh ()
forall a b. (a -> Sh b) -> a -> Sh b
sh1 Int -> Sh ()
forall a. Int -> Sh a
S.quietExit
terror :: Text -> Sh a
terror :: forall a. Text -> Sh a
terror = (Text -> Sh a) -> Text -> Sh a
forall a b. (a -> Sh b) -> a -> Sh b
sh1 Text -> Sh a
forall a. Text -> Sh a
S.terror
catch_sh :: (Exception e) => Sh a -> (e -> Sh a) -> Sh a
catch_sh :: forall e a. Exception e => Sh a -> (e -> Sh a) -> Sh a
catch_sh Sh a
a e -> Sh a
f = Sh [a] -> Sh a
forall a. Sh [a] -> Sh a
Sh (Sh [a] -> Sh a) -> Sh [a] -> Sh a
forall a b. (a -> b) -> a -> b
$ Sh [a] -> (e -> Sh [a]) -> Sh [a]
forall e a. Exception e => Sh a -> (e -> Sh a) -> Sh a
S.catch_sh (Sh a -> Sh [a]
forall a. Sh a -> Sh [a]
unSh Sh a
a) (Sh a -> Sh [a]
forall a. Sh a -> Sh [a]
unSh (Sh a -> Sh [a]) -> (e -> Sh a) -> e -> Sh [a]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. e -> Sh a
f)
catchany_sh :: Sh a -> (SomeException -> Sh a) -> Sh a
catchany_sh :: forall a. Sh a -> (SomeException -> Sh a) -> Sh a
catchany_sh = Sh a -> (SomeException -> Sh a) -> Sh a
forall e a. Exception e => Sh a -> (e -> Sh a) -> Sh a
catch_sh
finally_sh :: Sh a -> Sh b -> Sh a
finally_sh :: forall a b. Sh a -> Sh b -> Sh a
finally_sh = (Sh a -> Sh b -> Sh a) -> Sh a -> Sh b -> Sh a
forall a b c. (Sh a -> Sh b -> Sh c) -> Sh a -> Sh b -> Sh c
lift2 Sh a -> Sh b -> Sh a
forall a b. Sh a -> Sh b -> Sh a
S.finally_sh
time :: Sh a -> Sh (Double, a)
time :: forall a. Sh a -> Sh (Double, a)
time = (Sh a -> Sh (Double, a)) -> Sh a -> Sh (Double, a)
forall a b. (Sh a -> Sh b) -> Sh a -> Sh b
lift1 Sh a -> Sh (Double, a)
forall a. Sh a -> Sh (Double, a)
S.time
data ShellyHandler a = forall e . Exception e => ShellyHandler (e -> Sh a)
catches_sh :: Sh a -> [ShellyHandler a] -> Sh a
catches_sh :: forall a. Sh a -> [ShellyHandler a] -> Sh a
catches_sh Sh a
a [ShellyHandler a]
hs = Sh [a] -> Sh a
forall a. Sh [a] -> Sh a
Sh (Sh [a] -> Sh a) -> Sh [a] -> Sh a
forall a b. (a -> b) -> a -> b
$ Sh [a] -> [ShellyHandler [a]] -> Sh [a]
forall a. Sh a -> [ShellyHandler a] -> Sh a
S.catches_sh (Sh a -> Sh [a]
forall a. Sh a -> Sh [a]
unSh Sh a
a) ((ShellyHandler a -> ShellyHandler [a])
-> [ShellyHandler a] -> [ShellyHandler [a]]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ShellyHandler a -> ShellyHandler [a]
forall a. ShellyHandler a -> ShellyHandler [a]
convert [ShellyHandler a]
hs)
where convert :: ShellyHandler a -> S.ShellyHandler [a]
convert :: forall a. ShellyHandler a -> ShellyHandler [a]
convert (ShellyHandler e -> Sh a
f) = (e -> Sh [a]) -> ShellyHandler [a]
forall a e. Exception e => (e -> Sh a) -> ShellyHandler a
S.ShellyHandler (Sh a -> Sh [a]
forall a. Sh a -> Sh [a]
unSh (Sh a -> Sh [a]) -> (e -> Sh a) -> e -> Sh [a]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. e -> Sh a
f)
toTextWarn :: FilePath -> Sh Text
toTextWarn :: FilePath -> Sh Text
toTextWarn = (FilePath -> Sh Text) -> FilePath -> Sh Text
forall a b. (a -> Sh b) -> a -> Sh b
sh1 FilePath -> Sh Text
S.toTextWarn
get :: Sh State
get :: Sh State
get = Sh State -> Sh State
forall a. Sh a -> Sh a
sh0 Sh State
S.get
put :: State -> Sh ()
put :: State -> Sh ()
put = (State -> Sh ()) -> State -> Sh ()
forall a b. (a -> Sh b) -> a -> Sh b
sh1 State -> Sh ()
S.put
class ShellArg a where toTextArg :: a -> Text
instance ShellArg Text where toTextArg :: Text -> Text
toTextArg = Text -> Text
forall a. a -> a
id
instance ShellArg FilePath where toTextArg :: FilePath -> Text
toTextArg = FilePath -> Text
toTextIgnore
class ShellCommand t where
cmdAll :: FilePath -> [Text] -> t
instance ShellCommand (Sh Text) where
cmdAll :: FilePath -> [Text] -> Sh Text
cmdAll FilePath
fp [Text]
args = FilePath -> [Text] -> Sh Text
run FilePath
fp [Text]
args
instance (s ~ Text, Show s) => ShellCommand (Sh s) where
cmdAll :: FilePath -> [Text] -> Sh s
cmdAll FilePath
fp [Text]
args = FilePath -> [Text] -> Sh Text
run FilePath
fp [Text]
args
instance ShellCommand (Sh ()) where
cmdAll :: FilePath -> [Text] -> Sh ()
cmdAll FilePath
fp [Text]
args = FilePath -> [Text] -> Sh ()
run_ FilePath
fp [Text]
args
instance (ShellArg arg, ShellCommand result) => ShellCommand (arg -> result) where
cmdAll :: FilePath -> [Text] -> arg -> result
cmdAll FilePath
fp [Text]
acc = \arg
x -> FilePath -> [Text] -> result
forall t. ShellCommand t => FilePath -> [Text] -> t
cmdAll FilePath
fp ([Text]
acc [Text] -> [Text] -> [Text]
forall a. [a] -> [a] -> [a]
++ [arg -> Text
forall a. ShellArg a => a -> Text
toTextArg arg
x])
cmd :: (ShellCommand result) => FilePath -> result
cmd :: forall result. ShellCommand result => FilePath -> result
cmd FilePath
fp = FilePath -> [Text] -> result
forall t. ShellCommand t => FilePath -> [Text] -> t
cmdAll FilePath
fp []