extra_clean(['T706.hs'])],
run_command,
['$MAKE -s --no-print-directory T706'])
+test('spacesInArgs',
+ extra_run_opts('"a b" "c d" \'e f\' \'g h\''),
+ compile_and_run,
+ [''])
+
--- /dev/null
+
+import System.Environment
+
+main :: IO ()
+main = do args <- getArgs
+ mapM_ (putStrLn . f) args
+
+f :: String -> String
+f str = "Arg: " ++ show str
+
#else
run secs cmd =
+ let escape '\\' = "\\\\"
+ escape '"' = "\\\""
+ escape c = [c]
+ cmd' = "sh -c \"" ++ concatMap escape cmd ++ "\"" in
alloca $ \p_startupinfo ->
alloca $ \p_pi ->
- withTString ("sh -c \"" ++ cmd ++ "\"") $ \cmd' ->
+ withTString cmd' $ \cmd'' ->
do job <- createJobObjectW nullPtr nullPtr
let creationflags = 0
- b <- createProcessW nullPtr cmd' nullPtr nullPtr True
+ b <- createProcessW nullPtr cmd'' nullPtr nullPtr True
creationflags
nullPtr nullPtr p_startupinfo p_pi
unless b $ errorWin "createProcessW"