mirror of
https://github.com/kowainik/shellmet.git
synced 2024-09-11 09:55:42 +03:00
Generalise handle operator (#5)
This commit is contained in:
parent
217a9b34f6
commit
4187ef247c
@ -3,8 +3,12 @@
|
|||||||
`shellmet` uses [PVP Versioning][1].
|
`shellmet` uses [PVP Versioning][1].
|
||||||
The changelog is available [on GitHub][2].
|
The changelog is available [on GitHub][2].
|
||||||
|
|
||||||
0.0.0
|
## 0.0.1 — Apr 9, 2019
|
||||||
=====
|
|
||||||
|
* Generalise the type of the `$?` operator to allow returning values on
|
||||||
|
shell-command failuires.
|
||||||
|
|
||||||
|
## 0.0.0
|
||||||
|
|
||||||
* Initially created.
|
* Initially created.
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
cabal-version: 2.0
|
cabal-version: 2.0
|
||||||
name: shellmet
|
name: shellmet
|
||||||
version: 0.0.0
|
version: 0.0.1
|
||||||
synopsis: Out of the shell solution for scripting in Haskell
|
synopsis: Out of the shell solution for scripting in Haskell
|
||||||
description: Shellmet provides easy and convenient way to call shell commands from Haskell programs
|
description: Shellmet provides easy and convenient way to call shell commands from Haskell programs
|
||||||
homepage: https://github.com/kowainik/shellmet
|
homepage: https://github.com/kowainik/shellmet
|
||||||
|
@ -56,7 +56,7 @@ infix 5 $|
|
|||||||
($|) :: FilePath -> [Text] -> IO Text
|
($|) :: FilePath -> [Text] -> IO Text
|
||||||
cmd $| args = T.strip . T.pack <$> readProcess cmd (map T.unpack args) ""
|
cmd $| args = T.strip . T.pack <$> readProcess cmd (map T.unpack args) ""
|
||||||
|
|
||||||
{- | Do some IO actions when processed failed with error.
|
{- | Do some IO actions when process failed with 'IOError'.
|
||||||
|
|
||||||
>>> "exit" ["0"] $? putStrLn "Command failed"
|
>>> "exit" ["0"] $? putStrLn "Command failed"
|
||||||
⚙ exit 0
|
⚙ exit 0
|
||||||
@ -66,5 +66,5 @@ cmd $| args = T.strip . T.pack <$> readProcess cmd (map T.unpack args) ""
|
|||||||
Command failed
|
Command failed
|
||||||
-}
|
-}
|
||||||
infixl 4 $?
|
infixl 4 $?
|
||||||
($?) :: IO () -> IO () -> IO ()
|
($?) :: IO a -> IO a -> IO a
|
||||||
action $? handler = action `catch` \(_ :: IOError) -> handler
|
action $? handler = action `catch` \(_ :: IOError) -> handler
|
||||||
|
Loading…
Reference in New Issue
Block a user