summaryrefslogtreecommitdiff
path: root/src/Utility
diff options
context:
space:
mode:
authorJoey Hess2015-06-01 13:56:30 -0400
committerJoey Hess2015-06-01 13:56:30 -0400
commita5bb972d94b2e29f73ecfa4abab275400d0caeef (patch)
tree41cc0e2c758ab6018c8db08877deb0aa11d54b77 /src/Utility
parent446a2e4c9a3fe27782fd6d5d3228fc83a83fe82a (diff)
remove Params constructor
Before it gets into released API...
Diffstat (limited to 'src/Utility')
-rw-r--r--src/Utility/SafeCommand.hs14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/Utility/SafeCommand.hs b/src/Utility/SafeCommand.hs
index 82e35049..9102b726 100644
--- a/src/Utility/SafeCommand.hs
+++ b/src/Utility/SafeCommand.hs
@@ -19,25 +19,23 @@ import Prelude
-- | Parameters that can be passed to a shell command.
data CommandParam
- = Params String -- ^ Contains multiple parameters, separated by whitespace
- | Param String -- ^ A single parameter
+ = Param String -- ^ A parameter
| File FilePath -- ^ The name of a file
deriving (Eq, Show, Ord)
-- | Used to pass a list of CommandParams to a function that runs
-- a command and expects Strings. -}
toCommand :: [CommandParam] -> [String]
-toCommand = concatMap unwrap
+toCommand = map unwrap
where
- unwrap (Param s) = [s]
- unwrap (Params s) = filter (not . null) (split " " s)
+ unwrap (Param s) = s
-- Files that start with a non-alphanumeric that is not a path
-- separator are modified to avoid the command interpreting them as
-- options or other special constructs.
unwrap (File s@(h:_))
- | isAlphaNum h || h `elem` pathseps = [s]
- | otherwise = ["./" ++ s]
- unwrap (File s) = [s]
+ | isAlphaNum h || h `elem` pathseps = s
+ | otherwise = "./" ++ s
+ unwrap (File s) = s
-- '/' is explicitly included because it's an alternative
-- path separator on Windows.
pathseps = pathSeparator:"./"