summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-08-21 13:17:12 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-08-21 13:17:12 -0400
commit06ce5741365ae4602ca64204729e6a23705059ee (patch)
tree0cfff51a9cc7868a9e0b533fd87672a789e08494
parent1c25df3c1b19ad8406cbe2aef9dfd215ef9f5ce8 (diff)
tweak
-rw-r--r--Config.hs5
-rw-r--r--Utility.hs6
2 files changed, 5 insertions, 6 deletions
diff --git a/Config.hs b/Config.hs
index 568eb7138..493a90700 100644
--- a/Config.hs
+++ b/Config.hs
@@ -51,11 +51,10 @@ remoteCost r def = do
else getConfig r "cost" ""
where
safeparse v
- | null ws || null ps = def
- | otherwise = (fst . head) ps
+ | null ws = def
+ | otherwise = fromMaybe def $ readMaybe $ head ws
where
ws = words v
- ps = reads $ head ws
cheapRemoteCost :: Int
cheapRemoteCost = 100
diff --git a/Utility.hs b/Utility.hs
index 511350898..8a332601b 100644
--- a/Utility.hs
+++ b/Utility.hs
@@ -75,7 +75,7 @@ toCommand = (>>= unwrap)
unwrap (Params s) = filter (not . null) (split " " s)
-- Files that start with a dash are modified to avoid
-- the command interpreting them as options.
- unwrap (File ('-':s)) = ["./-" ++ s]
+ unwrap (File s@('-':_)) = ["./" ++ s]
unwrap (File s) = [s]
{- Run a system command, and returns True or False
@@ -257,7 +257,7 @@ viaTmp a file content = do
{- Runs an action with a temp file, then removes the file. -}
withTempFile :: String -> (FilePath -> Handle -> IO a) -> IO a
-withTempFile template action = bracket create remove use
+withTempFile template a = bracket create remove use
where
create = do
tmpdir <- catch getTemporaryDirectory (const $ return ".")
@@ -265,7 +265,7 @@ withTempFile template action = bracket create remove use
remove (name, handle) = do
hClose handle
catchBool (removeFile name >> return True)
- use (name, handle) = action name handle
+ use (name, handle) = a name handle
{- Lists the contents of a directory.
- Unlike getDirectoryContents, paths are not relative to the directory. -}