shelly 1.8.1 → 1.8.2
raw patch · 9 files changed
+165/−71 lines, 9 filesdep +faildep −unixdep ~basedep ~timenew-uploader
Dependencies added: fail
Dependencies removed: unix
Dependency ranges changed: base, time
Files
- ChangeLog.md +78/−12
- README.md +2/−1
- shelly.cabal +43/−23
- src/Shelly.hs +10/−8
- src/Shelly/Base.hs +10/−6
- src/Shelly/Directory.hs +1/−13
- test/src/FindSpec.hs +1/−2
- test/src/RunSpec.hs +16/−5
- test/src/TestInit.hs +4/−1
ChangeLog.md view
@@ -1,49 +1,115 @@+# 1.8.2++Andreas Abel, 2022-03-24++Version still using the `system-filepath` and `system-fileio` packages,+fixes issue [#189](https://github.com/gregwebs/Shelly.hs/issues/189).++* Builds with GHC 7.4 - 9.2.+* Backport `MonadFail` fixes from 1.9.0.+* Remove `unix` dependency in favor of `unix-compat`.+* Allow `time-1.12`.+* Backport CI on GitHub Action testing on Linux with GHC 7.4 - 9.2, on Windows/macOS with 8.8 - 9.2.+ # 1.8.1 -There is a new function `cp_should_follow_symlinks` to specify whether a copy should follow symlinks.+Greg Weber, 2018-05-30+* New function `cp_should_follow_symlinks` to specify whether a copy should follow symlinks. # 1.8.0 -* `cp_r` now uses upper case R: `cp -R`+Greg Weber, 2018-05-09+* `cp_r` now uses upper case R: `cp -R`. # 1.7.2 -* Support exceptions-0.9+Greg Weber, 2018-03-17+* Fix handling of case-insensitive environment variables on Windows.+ [#166](https://github.com/yesodweb/Shelly.hs/issues/166) +# 1.7.1++Greg Weber, 2018-03-06+* Support `exceptions-0.9`.+ # 1.7.0.1 -* Fix FindSpec.hs tests. Fixes [#150](https://github.com/yesodweb/Shelly.hs/issues/150), [#162](https://github.com/yesodweb/Shelly.hs/issues/162)+Greg Weber, 2018-01-23+* Fix `FindSpec.hs` tests.+ Fixes [#150](https://github.com/yesodweb/Shelly.hs/issues/150)+ and [#162](https://github.com/yesodweb/Shelly.hs/issues/162). +# 1.7.0++Greg Weber, 2017-12-10+* Quote `ssh` remote commands aggressively with single quotes.+ [#160](https://github.com/yesodweb/Shelly.hs/issues/160)++# 1.6.9++Greg Weber, 2017-12-07+* Strongly escape `ssh` commands.+* Add `sshPairsP`: parallel execution of `ssh` commands.+ # 1.6.8.7 -* Relax unix-compat constraints+Sibi Prabakaran, 2017-11-26+* Relax `unix-compat` constraints. # 1.6.8.6 +Sibi Prabakaran, 2017-11-19 * Fix Build issue [#156](https://github.com/yesodweb/Shelly.hs/issues/156) # 1.6.8.5 +Sibi Prabakaran, 2017-11-12 * Fix Windows build [#155](https://github.com/yesodweb/Shelly.hs/pull/155) +# 1.6.8.4++Greg Weber, 2017-08-07+* Option `followSymlink` for find-command.+* Allow `time-1.7/8`.++# 1.6.8.3++Greg Weber, 2017-03-03+* Support GHC 8.0.2++# 1.6.8.2++Greg Weber, 2017-03-03+* Allow `time-1.6`and `directory-1.3`++# 1.6.8.1++Greg Weber, 2016-10-02+* _changelog missing_+ # 1.6.8 -* added sshPairsWithOptions function+Greg Weber, 2016-06-26+* Added `sshPairsWithOptions` function. # 1.6.7 -* flush stdout when using `echo`, not just `echo_n`-* fix should be able to silence stderr when using `runHandle`-* expose RunFailed+Greg Weber, 2016-06-24+* Flush `stdout` when using `echo`, not just `echo_n`.+* Fix should be able to silence `stderr` when using `runHandle`.+* Expose `RunFailed`. # 1.6.6 -* add prependToPath function+Greg Weber, 2016-04-21+* Add `prependToPath` function. # 1.6.5 -* expose MonadShControl+Greg Weber, 2015-12-10+* Expose `MonadShControl`. # 1.6.4.1 -* add writeBinary function+Greg Weber, 2015-12-01+* Add `writeBinary` function.
README.md view
@@ -1,6 +1,7 @@ # Shelly -[](https://travis-ci.org/yesodweb/Shelly.hs)+[](https://github.com/gregwebs/Shelly.hs/actions/workflows/haskell-ci.yml)+[](https://github.com/gregwebs/Shelly.hs/actions/workflows/mac-win-ci.yml) [](https://hackage.haskell.org/package/shelly) [](http://stackage.org/nightly/package/shelly) [](http://stackage.org/lts/package/shelly)
shelly.cabal view
@@ -1,6 +1,6 @@ Name: shelly -Version: 1.8.1+Version: 1.8.2 Synopsis: shell-like (systems) programming in Haskell Description: Shelly provides convenient systems programming in Haskell,@@ -19,18 +19,32 @@ . See the shelly-extra package for additional functionality. .- An overview is available in the README: <https://github.com/yesodweb/Shelly.hs/blob/master/README.md>+ An overview is available in the README: <https://github.com/gregwebs/Shelly.hs/blob/master/README.md> -Homepage: https://github.com/yesodweb/Shelly.hs+Homepage: https://github.com/gregwebs/Shelly.hs License: BSD3 License-file: LICENSE Author: Greg Weber, Petr Rockai-Maintainer: Greg Weber <greg@gregweber.info>+Maintainer: Andreas Abel Category: Development Build-type: Simple-Cabal-version: >=1.8+Cabal-version: >=1.10 +tested-with:+ GHC == 9.2.2+ GHC == 9.0.2+ GHC == 8.10.7+ GHC == 8.8.4+ GHC == 8.6.5+ GHC == 8.4.4+ GHC == 8.2.2+ GHC == 8.0.2+ GHC == 7.10.3+ GHC == 7.8.4+ GHC == 7.6.3+ GHC == 7.4.2+ -- for the sdist of the test suite extra-source-files: test/src/*.hs test/examples/*.sh@@ -48,13 +62,13 @@ hs-source-dirs: src Build-depends:+ base >= 4 && < 5, containers >= 0.4.2.0,- time >= 1.3 && < 1.9,+ time >= 1.3 && < 1.13, directory >= 1.3.0.0 && < 1.4.0.0, mtl >= 2, process >= 1.0, unix-compat < 0.6,- unix, system-filepath >= 0.4.7 && < 0.5, system-fileio < 0.4, monad-control >= 0.3.2 && < 1.1,@@ -64,24 +78,22 @@ enclosed-exceptions, text, bytestring, async, transformers, transformers-base - if impl(ghc >= 7.6.1)- build-depends:- base >= 4.6 && < 5- else- build-depends:- base >= 4 && < 5 + if impl(ghc < 8.0)+ build-depends: fail >= 4.9 && < 4.10+ ghc-options: -Wall if impl(ghc >= 7.6.1) CPP-Options: -DNO_PRELUDE_CATCH - extensions:+ default-language: Haskell2010+ default-extensions: CPP source-repository head type: git- location: https://github.com/yesodweb/Shelly.hs+ location: https://github.com/gregwebs/Shelly.hs Flag lifted Description: run the tests against Shelly.Lifted@@ -105,17 +117,22 @@ SshSpec Shelly Shelly.Base+ Shelly.Directory Shelly.Find Shelly.Lifted TestInit WhichSpec WriteSpec - ghc-options: -O2 -Wall -fwarn-tabs -funbox-strict-fields -threaded+ ghc-options: -Wall -fwarn-tabs -funbox-strict-fields -threaded -fno-warn-unused-do-bind -fno-warn-type-defaults - extensions: OverloadedStrings, ExtendedDefaultRules+ default-language: Haskell2010+ default-extensions:+ CPP+ OverloadedStrings+ ExtendedDefaultRules if flag(lifted) cpp-options: -DLIFTED@@ -129,11 +146,10 @@ directory >= 1.3.0.0 && < 1.4.0.0, process >= 1.1.0, unix-compat < 0.6,- unix, system-filepath >= 0.4.7 && < 0.5, system-fileio < 0.4,- time >= 1.3 && < 1.9, mtl >= 2,+ time >= 1.3 && < 1.13, HUnit >= 1.2, hspec >= 2.0, hspec-contrib,@@ -146,8 +162,8 @@ enclosed-exceptions, exceptions - extensions:- CPP+ if impl(ghc < 8.0)+ build-depends: fail >= 4.9 && < 4.10 Flag build-examples Description: build some example programs@@ -166,7 +182,8 @@ , shelly , text - extensions:+ default-language: Haskell2010+ default-extensions: CPP else buildable: False@@ -181,7 +198,8 @@ , shelly , text - extensions:+ default-language: Haskell2010+ default-extensions: CPP else buildable: False@@ -198,3 +216,5 @@ , text else buildable: False++ default-language: Haskell2010
src/Shelly.hs view
@@ -765,7 +765,7 @@ setPath $ pe <> T.singleton searchPathSeparator <> tp -- | prepend the filepath to the PATH env variable--- similar to `appendToPath` but gives high priority to the filepath instead of low priority.+-- similar to 'appendToPath' but gives high priority to the filepath instead of low priority. prependToPath :: FilePath -> Sh () prependToPath = traceAbsPath ("prependToPath: " <>) >=> \filepath -> do tp <- toTextWarn filepath@@ -1200,7 +1200,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_.+-- | 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 @@ -1212,13 +1212,13 @@ where sanitise = T.replace "'" "\'" . T.intercalate " " --- | Use this with `bash` to set _pipefail_+-- | 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:+-- | bind some arguments to 'run' for re-use. Example: -- -- > monit = command "monit" ["-c", "monitrc"] -- > monit ["stop", "program"]@@ -1232,15 +1232,17 @@ command_ :: FilePath -> [Text] -> [Text] -> Sh () command_ com args more_args = run_ com (args ++ more_args) --- | bind some arguments to run for re-use, and require 1 argument. Example:+-- | bind some arguments to 'run' for re-use, and require 1 argument. Example: ----- > git = command1 "git" []; git "pull" ["origin", "master"]+-- > git = command1 "git" []+-- > git "pull" ["origin", "master"] command1 :: FilePath -> [Text] -> Text -> [Text] -> Sh Text command1 com args one_arg more_args = run com (args ++ [one_arg] ++ more_args) --- | bind some arguments to run for re-use, and require 1 argument. Example:+-- | bind some arguments to 'run_' for re-use, and require 1 argument. Example: ----- > git_ = command1_ "git" []; git "pull" ["origin", "master"]+-- > git_ = command1_ "git" []+-- > git "pull" ["origin", "master"] command1_ :: FilePath -> [Text] -> Text -> [Text] -> Sh () command1_ com args one_arg more_args = run_ com (args ++ [one_arg] ++ more_args)
src/Shelly/Base.hs view
@@ -8,10 +8,7 @@ {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE UndecidableInstances #-} {-# LANGUAGE DeriveDataTypeable #-}-{-# LANGUAGE InstanceSigs#-}--- | I started exposing multiple module (starting with one for finding)--- Base prevented circular dependencies--- However, Shelly went back to exposing a single module+ module Shelly.Base ( Sh(..), ShIO, runSh, State(..), ReadOnlyState(..), StdHandle(..),@@ -44,6 +41,8 @@ import Control.Monad (when, (>=>), liftM )+import Control.Monad.Fail (MonadFail)+import qualified Control.Monad.Fail as Fail import Control.Monad.Base import Control.Monad.Trans.Control import Control.Applicative (Applicative, (<$>))@@ -71,8 +70,14 @@ newtype Sh a = Sh { unSh :: ReaderT (IORef State) IO a- } deriving (Applicative, Monad, MonadIO, MonadReader (IORef State), Functor, Catch.MonadMask)+ } deriving (Functor, Applicative, Monad, MonadIO, MonadReader (IORef State), Catch.MonadMask) --, MonadFail) +-- Andreas Abel, 2022-03-24+-- For reasons unclear to me, GHC 7.10 does not derive the MonadFail instance+-- from the instances for IO and ReaderT. Starts working with GHC 8.0.+instance MonadFail Sh where+ fail = Sh . ReaderT . const . Fail.fail+ instance MonadBase IO Sh where liftBase = Sh . ReaderT . const @@ -321,4 +326,3 @@ -- @... `catch` \(e :: SomeException) -> ...@). catchany :: IO a -> (SomeException -> IO a) -> IO a catchany = catch-
src/Shelly/Directory.hs view
@@ -4,29 +4,17 @@ import System.IO.Error (modifyIOError, ioeSetLocation, ioeGetLocation) import qualified Filesystem.Path.CurrentOS as FP -#ifdef mingw32_HOST_OS-import qualified System.Win32 as Win32-#else-import qualified System.Posix as Posix-#endif+import qualified System.PosixCompat as Posix createFileLink :: String -> String -> IO () createFileLink target link = (`ioeAddLocation` "createFileLink") `modifyIOError` do-#ifdef mingw32_HOST_OS- Win32.createSymbolicLink False target link-#else Posix.createSymbolicLink target link-#endif getSymbolicLinkTarget :: String -> IO String getSymbolicLinkTarget path = (`ioeAddLocation` "getSymbolicLinkTarget") `modifyIOError` do-#ifdef mingw32_HOST_OS- Win32.readSymbolicLink path-#else Posix.readSymbolicLink path-#endif ioeAddLocation :: IOError -> String -> IOError ioeAddLocation e loc = do
test/src/FindSpec.hs view
@@ -84,7 +84,7 @@ "TestInit.hs", "TestMain.hs", "WhichSpec.hs", "WriteSpec.hs", "sleep.hs"] - before createSymlinkForTest $ do+ unless isWindows $ before createSymlinkForTest $ do it "follow symlinks" $ do res <- shelly $@@ -112,4 +112,3 @@ , "dir/symlinked_dir" , "symlinked_dir/hoge_file" ]-
test/src/RunSpec.hs view
@@ -18,12 +18,16 @@ it "without escaping" $ do res <- shelly $ escaping False $ run "echo" [ "*" ]- assert $ "README.md" `elem` T.words res+ if isWindows+ then res @?= "*\n"+ else assert $ "README.md" `elem` T.words res it "with binary handle mode" $ do res <- shelly $ onCommandHandles (initOutputHandles (flip hSetBinaryMode True)) $ run "cat" [ "test/data/nonascii.txt" ]- res @?= "Selbstverst\228ndlich \252berraschend\n"+ if isWindows+ then res @?= "Selbstverst\228ndlich \252berraschend\r\n"+ else res @?= "Selbstverst\228ndlich \252berraschend\n" -- Bash-related commands describe "bash" $ do@@ -38,7 +42,9 @@ it "with binary handle mode" $ do res <- shelly $ onCommandHandles (initOutputHandles (flip hSetBinaryMode True)) $ bash "cat" [ "test/data/nonascii.txt" ]- res @?= "Selbstverst\228ndlich \252berraschend\n"+ if isWindows+ then res @?= "Selbstverst\228ndlich \252berraschend\r\n"+ else res @?= "Selbstverst\228ndlich \252berraschend\n" {- This throws spurious errors on some systems it "can detect failing commands in pipes" $ do@@ -51,8 +57,13 @@ it "preserve pipe behaviour" $ do (eCode, res) <- shelly $ escaping False $ errExit False $ do- res <- bash "echo" [ "'foo'", "|", "echo", "'bar'" ]+ res <-+ if isWindows+ then bash "echo" [ "foo", "|", "echo", "bar" ]+ else bash "echo" [ "'foo'", "|", "echo", "'bar'" ] eCode <- lastExitCode return (eCode, res)- res @?= "bar\n"+ if isWindows+ then res @?= "bar'\n"+ else res @?= "bar\n" eCode @?= 0
test/src/TestInit.hs view
@@ -1,4 +1,4 @@-module TestInit (module Export) where+module TestInit (module Export, isWindows) where import Test.HUnit as Export hiding (path) import Test.Hspec as Export@@ -8,3 +8,6 @@ import Shelly as Export #endif import Test.Hspec.Contrib.HUnit ()+import System.Info(os)+isWindows :: Bool +isWindows = os == "mingw32"