summaryrefslogtreecommitdiff
path: root/src/Propellor/Property/Cmd.hs
diff options
context:
space:
mode:
authorJoey Hess2015-05-27 12:39:29 -0400
committerJoey Hess2015-05-27 12:39:29 -0400
commit315a5688b890688fbc3aa6271310f17d0beabcca (patch)
tree203233f6b4322bd522886813b469a5e63890058c /src/Propellor/Property/Cmd.hs
parentaeb47743d770e8970d642d92a777f23c1566ef75 (diff)
parent626f1af56f12be63cd78fa4910c55453c23cf5a0 (diff)
Merge branch 'joeyconfig'
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)