shh 0.3.1.2 → 0.3.1.3
raw patch · 2 files changed
+9/−2 lines, 2 files
Files
- shh.cabal +1/−1
- src/Shh/Internal.hs +8/−1
shh.cabal view
@@ -1,5 +1,5 @@ name: shh-version: 0.3.1.2+version: 0.3.1.3 synopsis: Simple shell scripting from Haskell description: Provides a shell scripting environment for Haskell. It helps you all external binaries, and allows you to
src/Shh/Internal.hs view
@@ -400,13 +400,18 @@ pathsVar <- splitOn ":" <$> getEnv "PATH" paths <- filterM Dir.doesDirectoryExist pathsVar ps <- ordNubOn takeFileName . concat <$> mapM (\d -> fmap (\x -> d++('/':x)) <$> Dir.getDirectoryContents d) paths- filterM (fmap Dir.executable . Dir.getPermissions) ps+ filterM (tryBool . 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 + tryBool :: IO Bool -> IO Bool+ tryBool a = try a >>= \case+ Left (SomeException _) -> pure False+ Right r -> pure r+ -- | Execute the given command. Further arguments can be passed in. -- -- > exe "ls" "-l"@@ -459,6 +464,8 @@ -- is some chance of overlap. If the string is a path, the filename portion -- is used. The transformation replaces all non-alphanumeric characters -- with @'_'@. If the first character is uppercase it is forced into lowercase.+-- If it starts with a number, it is prefixed with `_`. If it overlaps with+-- a reserved word or a builtin, it is suffixed with an `_`. encodeIdentifier :: String -> String encodeIdentifier ident = let