shh 0.4.0.0 → 0.4.0.1
raw patch · 3 files changed
+31/−2 lines, 3 filesPVP: minor bump suggested
API additions: PVP suggests at least a minor version bump
API changes (from Hackage documentation)
+ Shh: loadAnnotatedFromDirs :: [FilePath] -> (String -> String) -> Q [Dec]
+ Shh: loadFromBins :: [FilePath] -> Q [Dec]
+ Shh: loadFromDirs :: [FilePath] -> Q [Dec]
+ Shh.Internal: findBinsIn :: [FilePath] -> IO [FilePath]
+ Shh.Internal: loadAnnotatedFromDirs :: [FilePath] -> (String -> String) -> Q [Dec]
+ Shh.Internal: loadFromBins :: [FilePath] -> Q [Dec]
+ Shh.Internal: loadFromDirs :: [FilePath] -> Q [Dec]
Files
- shh.cabal +1/−1
- src/Shh.hs +3/−0
- src/Shh/Internal.hs +27/−1
shh.cabal view
@@ -1,5 +1,5 @@ name: shh-version: 0.4.0.0+version: 0.4.0.1 synopsis: Simple shell scripting from Haskell description: Provides a shell scripting environment for Haskell. It helps you use external binaries, and allows you to
src/Shh.hs view
@@ -90,8 +90,11 @@ , ExecReference(..) , load , loadEnv+ , loadFromDirs+ , loadFromBins , loadAnnotated , loadAnnotatedEnv+ , loadAnnotatedFromDirs , loadExe , loadExeAs , pathBins
src/Shh/Internal.hs view
@@ -38,7 +38,7 @@ import qualified System.Directory as Dir import System.Environment (getEnv, setEnv) import System.Exit (ExitCode(..))-import System.FilePath (takeFileName)+import System.FilePath (takeFileName, (</>)) import System.IO import System.IO.Error import System.Posix.Signals@@ -592,6 +592,12 @@ pathBinsAbs = do pathsVar <- splitOn ":" <$> getEnv "PATH" paths <- filterM Dir.doesDirectoryExist pathsVar+ findBinsIn paths++-- | Get all uniquely named executables from the list of directories. Returns+-- a list of absolute file names.+findBinsIn :: [FilePath] -> IO [FilePath]+findBinsIn paths = do ps <- ordNubOn takeFileName . concat <$> mapM (\d -> fmap (\x -> d++('/':x)) <$> Dir.getDirectoryContents d) paths filterM (tryBool . fmap Dir.executable . Dir.getPermissions) ps @@ -731,6 +737,26 @@ -- ["a","b"] split :: String -> String -> [String] split = endBy++-- | Load executables from the given directories+loadFromDirs :: [FilePath] -> Q [Dec]+loadFromDirs ps = loadAnnotatedFromDirs ps encodeIdentifier++-- | Load executables from the given directories appended with @"/bin"@.+--+-- Useful for use with Nix.+-- +loadFromBins :: [FilePath] -> Q [Dec]+loadFromBins = loadFromDirs . fmap (</> "bin")++-- | Load executables from the given dirs, applying the given transformation+-- to the filenames.+loadAnnotatedFromDirs :: [FilePath] -> (String -> String) -> Q [Dec]+loadAnnotatedFromDirs ps f = do+ bins <- runIO $ findBinsIn ps+ i <- forM bins $ \bin -> do+ rawExe (f $ takeFileName bin) bin+ pure (concat i) -- | Function that splits '\0' separated list of strings. Useful in conjunction -- with @find . "-print0"@.