packages feed

shelly 0.13.2 → 0.13.2.1

raw patch · 4 files changed

+32/−15 lines, 4 filesPVP: minor bump suggested

API additions: PVP suggests at least a minor version bump

API changes (from Hackage documentation)

+ Shelly: instance [incoherent] Exception QuietExit
+ Shelly: instance [incoherent] Show QuietExit
+ Shelly: instance [incoherent] Typeable QuietExit
+ Shelly: quietExit :: Int -> Sh ()

Files

Shelly.hs view
@@ -56,7 +56,7 @@          , readfile, writefile, appendfile, touchfile, withTmpDir           -- * exiting the program-         , exit, errorExit, terror+         , exit, errorExit, quietExit, terror           -- * Exceptions          , catchany, catch_sh, finally_sh, ShellyHandler(..), catches_sh, catchany_sh@@ -367,6 +367,7 @@ pwd :: Sh FilePath pwd = gets sDirectory `tag` "pwd" +-- | exit 0 means no errors, all other codes are error conditions exit :: Int -> Sh () exit 0 = liftIO (exitWith ExitSuccess) `tag` "exit 0" exit n = liftIO (exitWith (ExitFailure n)) `tag` ("exit " `mappend` LT.pack (show n))@@ -375,6 +376,11 @@ errorExit :: Text -> Sh () errorExit msg = echo msg >> exit 1 +-- | for exiting with status > 0 without printing debug information+quietExit :: Int -> Sh ()+quietExit 0 = exit 0+quietExit n = throw $ QuietExit n+ -- | fail that takes a Text terror :: Text -> Sh a terror = fail . LT.unpack@@ -575,6 +581,8 @@                   ExitSuccess   -> liftIO $ throwIO ex                   ExitFailure _ -> throwExplainedException ex               )+            , ShellyHandler (\ex -> case ex of+                                     QuietExit n -> liftIO $ throwIO $ ExitFailure n)             , ShellyHandler (\(ex::SomeException) -> throwExplainedException ex)           ]   liftIO $ runSh caught stref@@ -658,6 +666,9 @@   where     toSSH (exe,args) = show_command exe args ++data QuietExit = QuietExit Int deriving (Show, Typeable)+instance Exception QuietExit  data ReThrownException e = ReThrownException e String deriving (Typeable) instance Exception e => Exception (ReThrownException e)
Shelly/Base.hs view
@@ -8,7 +8,7 @@     relPath, path, absPath, canonic, canonicalize,     test_d, test_s,     unpack, gets, get, modify, trace,-    ls,+    ls, lsRelAbs,     toTextIgnore,     echo, echo_n, echo_err, echo_n_err, inspect, inspect_err,     catchany,@@ -192,14 +192,19 @@ -- include (other) hidden files. ls :: FilePath -> Sh [FilePath] -- it is important to use path and not absPath so that the listing can remain relative-ls f = absPath f >>= \fp -> do+ls fp = do   trace $ "ls " `mappend` toTextIgnore fp-  filt <- if not (relative f) then return (return)+  fmap fst $ lsRelAbs fp++lsRelAbs :: FilePath -> Sh ([FilePath], [FilePath])+lsRelAbs f = absPath f >>= \fp -> do+  filt <- if not (relative f) then return return              else do                wd <- gets sDirectory                return (relativeTo wd)-  contents <- liftIO $ listDirectory fp-  mapM filt contents+  absolute <- liftIO $ listDirectory fp+  relativized <- mapM filt absolute+  return (relativized, absolute)  -- | silently uses the Right or Left value of "Filesystem.Path.CurrentOS.toText" toTextIgnore :: FilePath -> Text
Shelly/Find.hs view
@@ -57,15 +57,16 @@   absDir <- absPath dir   trace ("find " `mappend` toTextIgnore absDir)   filt <- dirFilter absDir-  if filt+  if not filt then return startValue     -- use possible relative path, not absolute so that listing will remain relative-    then ls dir >>= foldM traverse startValue-    else return startValue+    else do+      (rPaths, aPaths) <- lsRelAbs dir +      foldM traverse startValue (zip rPaths aPaths)   where-    traverse acc x = do+    traverse acc (relPath, absPath) = do       -- optimization: don't use Shelly API since our path is already good-      isDir <- liftIO $ isDirectory x-      sym   <- liftIO $ fmap isSymbolicLink $ getSymbolicLinkStatus (unpack x)+      isDir <- liftIO $ isDirectory absPath+      sym   <- liftIO $ fmap isSymbolicLink $ getSymbolicLinkStatus (unpack absPath)       if isDir && not sym-        then findFold folder acc x-        else folder acc x+        then findFold folder acc relPath+        else folder acc relPath
shelly.cabal view
@@ -1,6 +1,6 @@ Name:       shelly -Version:     0.13.2+Version:     0.13.2.1 Synopsis:    shell-like (systems) programming in Haskell  Description: Shelly provides convenient systems programming in Haskell,