From 626f1af56f12be63cd78fa4910c55453c23cf5a0 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 27 May 2015 12:38:45 -0400 Subject: Export CommandParam, boolSystem, safeSystem and shellEscape from Propellor.Property.Cmd, so they are available for use in constricting your own Properties when using propellor as a library. Several imports of Utility.SafeCommand now redundant. --- src/Propellor/Ssh.hs | 1 - 1 file changed, 1 deletion(-) (limited to 'src/Propellor/Ssh.hs') diff --git a/src/Propellor/Ssh.hs b/src/Propellor/Ssh.hs index 97c3eb6d..ac9295d1 100644 --- a/src/Propellor/Ssh.hs +++ b/src/Propellor/Ssh.hs @@ -1,7 +1,6 @@ module Propellor.Ssh where import Propellor -import Utility.SafeCommand import Utility.UserInfo import System.PosixCompat -- cgit v1.2.3 From a5bb972d94b2e29f73ecfa4abab275400d0caeef Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 1 Jun 2015 13:56:30 -0400 Subject: remove Params constructor Before it gets into released API... --- src/Propellor/Ssh.hs | 5 +++-- src/Utility/SafeCommand.hs | 14 ++++++-------- 2 files changed, 9 insertions(+), 10 deletions(-) (limited to 'src/Propellor/Ssh.hs') diff --git a/src/Propellor/Ssh.hs b/src/Propellor/Ssh.hs index ac9295d1..3fe78f7a 100644 --- a/src/Propellor/Ssh.hs +++ b/src/Propellor/Ssh.hs @@ -22,7 +22,8 @@ sshCachingParams hn = do let ps = [ Param "-o" , Param ("ControlPath=" ++ socketfile) - , Params "-o ControlMaster=auto -o ControlPersist=yes" + , Param "-o", Param "ControlMaster=auto" + , Param "-o", Param "ControlPersist=yes" ] maybe noop (expireold ps socketfile) @@ -37,7 +38,7 @@ sshCachingParams hn = do then touchFile f else do void $ boolSystem "ssh" $ - [ Params "-O stop" ] ++ ps ++ + [ Param "-O", Param "stop" ] ++ ps ++ [ Param "localhost" ] nukeFile f tenminutes = 600 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:"./" -- cgit v1.2.3