tweak
This commit is contained in:
parent
1c25df3c1b
commit
06ce574136
2 changed files with 5 additions and 6 deletions
|
@ -51,11 +51,10 @@ remoteCost r def = do
|
||||||
else getConfig r "cost" ""
|
else getConfig r "cost" ""
|
||||||
where
|
where
|
||||||
safeparse v
|
safeparse v
|
||||||
| null ws || null ps = def
|
| null ws = def
|
||||||
| otherwise = (fst . head) ps
|
| otherwise = fromMaybe def $ readMaybe $ head ws
|
||||||
where
|
where
|
||||||
ws = words v
|
ws = words v
|
||||||
ps = reads $ head ws
|
|
||||||
|
|
||||||
cheapRemoteCost :: Int
|
cheapRemoteCost :: Int
|
||||||
cheapRemoteCost = 100
|
cheapRemoteCost = 100
|
||||||
|
|
|
@ -75,7 +75,7 @@ toCommand = (>>= unwrap)
|
||||||
unwrap (Params s) = filter (not . null) (split " " s)
|
unwrap (Params s) = filter (not . null) (split " " s)
|
||||||
-- Files that start with a dash are modified to avoid
|
-- Files that start with a dash are modified to avoid
|
||||||
-- the command interpreting them as options.
|
-- the command interpreting them as options.
|
||||||
unwrap (File ('-':s)) = ["./-" ++ s]
|
unwrap (File s@('-':_)) = ["./" ++ s]
|
||||||
unwrap (File s) = [s]
|
unwrap (File s) = [s]
|
||||||
|
|
||||||
{- Run a system command, and returns True or False
|
{- 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. -}
|
{- Runs an action with a temp file, then removes the file. -}
|
||||||
withTempFile :: String -> (FilePath -> Handle -> IO a) -> IO a
|
withTempFile :: String -> (FilePath -> Handle -> IO a) -> IO a
|
||||||
withTempFile template action = bracket create remove use
|
withTempFile template a = bracket create remove use
|
||||||
where
|
where
|
||||||
create = do
|
create = do
|
||||||
tmpdir <- catch getTemporaryDirectory (const $ return ".")
|
tmpdir <- catch getTemporaryDirectory (const $ return ".")
|
||||||
|
@ -265,7 +265,7 @@ withTempFile template action = bracket create remove use
|
||||||
remove (name, handle) = do
|
remove (name, handle) = do
|
||||||
hClose handle
|
hClose handle
|
||||||
catchBool (removeFile name >> return True)
|
catchBool (removeFile name >> return True)
|
||||||
use (name, handle) = action name handle
|
use (name, handle) = a name handle
|
||||||
|
|
||||||
{- Lists the contents of a directory.
|
{- Lists the contents of a directory.
|
||||||
- Unlike getDirectoryContents, paths are not relative to the directory. -}
|
- Unlike getDirectoryContents, paths are not relative to the directory. -}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue