packages feed

shh 0.3.0.0 → 0.3.0.1

raw patch · 2 files changed

+22/−8 lines, 2 filesdep +containersPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

Dependencies added: containers

API changes (from Hackage documentation)

- Shh.Internal: instance (a Data.Type.Equality.~ ()) => GHC.Base.Monoid (Shh.Internal.Proc a)
- Shh.Internal: instance (a Data.Type.Equality.~ ()) => Shh.Internal.Unit (m a)
- Shh.Internal: instance (io Data.Type.Equality.~ GHC.Types.IO ()) => Shh.Internal.Cd io
- Shh.Internal: instance (io Data.Type.Equality.~ GHC.Types.IO (), path Data.Type.Equality.~ GHC.IO.FilePath) => Shh.Internal.Cd (path -> io)
- Shh.Internal: instance GHC.Exception.Type.Exception Shh.Internal.Failure
+ Shh.Internal: instance (a ~ ()) => GHC.Base.Monoid (Shh.Internal.Proc a)
+ Shh.Internal: instance (a ~ ()) => Shh.Internal.Unit (m a)
+ Shh.Internal: instance (io ~ GHC.Types.IO ()) => Shh.Internal.Cd io
+ Shh.Internal: instance (io ~ GHC.Types.IO (), path ~ GHC.IO.FilePath) => Shh.Internal.Cd (path -> io)
+ Shh.Internal: instance GHC.Exception.Exception Shh.Internal.Failure
+ Shh.Internal: pathBinsAbs :: IO [FilePath]
- Shh: withRead :: (PipeResult f, NFData b) => Proc a -> (String -> IO b) -> f b
+ Shh: withRead :: (PipeResult f, (NFData b)) => Proc a -> (String -> IO b) -> f b
- Shh.Internal: withRead :: (PipeResult f, NFData b) => Proc a -> (String -> IO b) -> f b
+ Shh.Internal: withRead :: (PipeResult f, (NFData b)) => Proc a -> (String -> IO b) -> f b

Files

shh.cabal view
@@ -1,5 +1,5 @@ name:                shh-version:             0.3.0.0+version:             0.3.0.1 synopsis:            Simple shell scripting from Haskell description:         Provides a shell scripting environment for Haskell. It                      helps you all external binaries, and allows you to@@ -32,6 +32,7 @@     process          >= 1.6.3 && < 1.7,     split            >= 0.2.3 && < 0.3,     template-haskell >= 2.13.0 && < 2.15,+    containers       >= 0.5.11 && < 0.7,     unix             >= 2.7.2 && < 2.8   hs-source-dirs:      src   default-language:    Haskell2010
src/Shh/Internal.hs view
@@ -19,13 +19,15 @@ import Control.Monad import Control.Monad.IO.Class import Data.Char (isLower, isSpace, isAlphaNum)-import Data.List (nub, dropWhileEnd, intercalate)+import Data.List (dropWhileEnd, intercalate) import Data.List.Split (endBy, splitOn)+import qualified Data.Map as Map import Data.Maybe (mapMaybe, isJust) import Language.Haskell.TH import qualified System.Directory as Dir import System.Environment (getEnv, setEnv) import System.Exit (ExitCode(..))+import System.FilePath (takeFileName) import System.IO import System.Posix.Signals import System.Process@@ -386,15 +388,26 @@ instance {-# OVERLAPPING #-} Unit b => Unit (a -> b) instance {-# OVERLAPPABLE #-} a ~ () => Unit (m a) --- | Get all files in a directory on your `$PATH`.------ TODO: Check for executability.+-- | Get all executables on your `$PATH`. pathBins :: IO [FilePath]-pathBins = do+pathBins = map takeFileName <$> pathBinsAbs++-- | Get all uniquely named executables on your `$PATH` as absolute+-- file names. The uniqueness is determined by the filename, and not+-- the whole path. First one found wins.+pathBinsAbs :: IO [FilePath]+pathBinsAbs = do     pathsVar <- splitOn ":" <$> getEnv "PATH"     paths <- filterM Dir.doesDirectoryExist pathsVar-    ps <- nub . concat <$> mapM Dir.getDirectoryContents paths-    filterM checkExecutable ps+    ps <- ordNubOn takeFileName . concat <$> mapM (\d -> fmap (\x -> d++('/':x)) <$> Dir.getDirectoryContents d) paths+    filterM (fmap Dir.executable . Dir.getPermissions) ps++    where+        -- TODO: Eventually replace this with nubOrdOn (containers 0.6.0.1 dep)+        ordNubOn :: Ord b => (a -> b) -> [a] -> [a]+        ordNubOn f as = map snd . Map.toList . Map.fromListWith const $ zip (map f as) as++  -- | Execute the given command. Further arguments can be passed in. --