11{-# LANGUAGE CPP #-}
2+ {-# LANGUAGE RankNTypes #-}
3+ {-# LANGUAGE TemplateHaskell #-}
4+ {-# LANGUAGE TupleSections #-}
25
36{-|
47Module : Stack.Sig.GPG
@@ -16,6 +19,7 @@ module Stack.Sig.GPG (signPackage, verifyFile) where
1619import Control.Applicative ((<$>) )
1720#endif
1821
22+ import Control.Exception (catch , SomeException )
1923import Control.Monad.Catch (MonadThrow , throwM )
2024import Control.Monad.IO.Class (MonadIO , liftIO )
2125import qualified Data.ByteString.Char8 as C
@@ -70,11 +74,14 @@ verifyFile (Signature signature) path = do
7074gpg
7175 :: (Monad m , MonadIO m )
7276 => [String ] -> String -> m (ExitCode , String , String )
73- gpg args stdin = do
74- (code,out,err) <- liftIO (readProcessWithExitCode " gpg2" args stdin)
75- if code == ExitSuccess
76- then return (code, out, err)
77- else liftIO (readProcessWithExitCode " gpg" args stdin)
78-
79- -- TODO test on Windows (package?)
80- -- TODO test on Mac (w/ GnuPG Suite & homebrew gnupg & gnupg2)
77+ gpg args stdin =
78+ liftIO
79+ (catch
80+ (readProcessWithExitCode " gpg2" args stdin)
81+ (oops
82+ (catch
83+ (readProcessWithExitCode " gpg" args stdin)
84+ (return . (, [] , [] )))))
85+ where
86+ oops :: IO a -> SomeException -> IO a
87+ oops = const
0 commit comments