summaryrefslogtreecommitdiff
path: root/src/Propellor/Property/Cmd.hs
diff options
context:
space:
mode:
authorJoey Hess2015-05-27 12:38:45 -0400
committerJoey Hess2015-05-27 12:38:45 -0400
commit626f1af56f12be63cd78fa4910c55453c23cf5a0 (patch)
tree201e7817c0c21a14d39a966a0249cb7ed3114f4b /src/Propellor/Property/Cmd.hs
parentd7ff70c7277f6a29fa608c8b1da1543c461a8bfc (diff)
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.
Diffstat (limited to 'src/Propellor/Property/Cmd.hs')
-rw-r--r--src/Propellor/Property/Cmd.hs20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/Propellor/Property/Cmd.hs b/src/Propellor/Property/Cmd.hs
index 859302c8..23f1075b 100644
--- a/src/Propellor/Property/Cmd.hs
+++ b/src/Propellor/Property/Cmd.hs
@@ -1,11 +1,20 @@
{-# LANGUAGE PackageImports #-}
module Propellor.Property.Cmd (
+ -- * Properties for running commands and scripts
cmdProperty,
cmdProperty',
cmdPropertyEnv,
+ Script,
scriptProperty,
userScriptProperty,
+ -- * Lower-level interface for running commands
+ CommandParam(..),
+ boolSystem,
+ boolSystemEnv,
+ safeSystem,
+ safeSystemEnv,
+ shellEscape
) where
import Control.Applicative
@@ -40,15 +49,18 @@ cmdPropertyEnv cmd params env = property desc $ liftIO $ do
where
desc = unwords $ cmd : params
--- | A property that can be satisfied by running a series of shell commands.
-scriptProperty :: [String] -> Property NoInfo
+-- | A series of shell commands. (Without a leading hashbang.)
+type Script = [String]
+
+-- | A property that can be satisfied by running a script.
+scriptProperty :: Script -> Property NoInfo
scriptProperty script = cmdProperty "sh" ["-c", shellcmd]
where
shellcmd = intercalate " ; " ("set -e" : script)
--- | A property that can satisfied by running a series of shell commands,
+-- | A property that can satisfied by running a script
-- as user (cd'd to their home directory).
-userScriptProperty :: User -> [String] -> Property NoInfo
+userScriptProperty :: User -> Script -> Property NoInfo
userScriptProperty (User user) script = cmdProperty "su" ["--shell", "/bin/sh", "-c", shellcmd, user]
where
shellcmd = intercalate " ; " ("set -e" : "cd" : script)