module Executor (execSync, exec, execSequenceSync, execListSync) where
import System.Process (readProcess)
split' :: String -> Char -> [String]
split' [] _ = [""]
split' (c:cs) delimiter
| c == delimiter = "" : rest
| otherwise = (c : head rest) : tail rest
where
rest = split' cs delimiter
execSync :: String -> IO String
execSync = exec
execListSync :: [String] -> IO [String]
execListSync = execSequenceSync
exec :: String -> IO String
exec c = readProcess command arguments []
where
commandList = split' c ' '
command = head commandList
arguments = tail commandList
execSequenceSync :: [String] -> IO [String]
execSequenceSync = mapM execSync