diff options
author | Roman Smrž <roman.smrz@seznam.cz> | 2025-10-02 21:00:15 +0200 |
---|---|---|
committer | Roman Smrž <roman.smrz@seznam.cz> | 2025-10-02 21:29:08 +0200 |
commit | 8b21c8de4a31c47510ed0f9b38adfcac0989f4e2 (patch) | |
tree | 8fdf6a383c60b1b549850a16f9f4fd5a5d01f7d0 | |
parent | 612e329ff8fab4b50fbe6d21f39842ced351eb57 (diff) |
Shell: remove special handling of echo
-rw-r--r-- | src/Script/Shell.hs | 40 |
1 files changed, 18 insertions, 22 deletions
diff --git a/src/Script/Shell.hs b/src/Script/Shell.hs index 5ac1240..b59a29c 100644 --- a/src/Script/Shell.hs +++ b/src/Script/Shell.hs @@ -17,7 +17,6 @@ import Control.Monad.Reader import Data.Maybe import Data.Text (Text) import Data.Text qualified as T -import Data.Text.IO qualified as T import Foreign.C.Types import Foreign.Ptr @@ -107,27 +106,24 @@ handledHandle (KeepHandle h) = h executeCommand :: ShellExecInfo -> HandleHandling -> HandleHandling -> HandleHandling -> ShellCommand -> TestRun () executeCommand ShellExecInfo {..} pstdin pstdout pstderr scmd@ShellCommand {..} = do let args = cmdArguments scmd - case cmdCommand of - "echo" -> liftIO $ do - T.hPutStrLn (handledHandle pstdout) $ T.intercalate " " args - hFlush (handledHandle pstdout) - mapM_ closeIfRequested [ pstdin, pstdout, pstderr ] - cmd -> do - (_, _, _, phandle) <- liftIO $ createProcess_ "shell" - (proc (T.unpack cmd) (map T.unpack args)) - { std_in = UseHandle $ handledHandle pstdin - , std_out = UseHandle $ handledHandle pstdout - , std_err = UseHandle $ handledHandle pstderr - , cwd = Just (nodeDir seiNode) - , env = Just [] - } - mapM_ closeIfRequested [ pstdin, pstdout, pstderr ] - liftIO (waitForProcess phandle) >>= \case - ExitSuccess -> return () - status -> do - outLine OutputChildFail (Just $ textProcName seiProcName) $ "failed at: " <> textSourceLine cmdSourceLine - liftIO $ putMVar seiStatusVar status - throwError Failed + phandle <- liftIO $ do + (_, _, _, phandle) <- createProcess_ "shell" + (proc (T.unpack cmdCommand) (map T.unpack args)) + { std_in = UseHandle $ handledHandle pstdin + , std_out = UseHandle $ handledHandle pstdout + , std_err = UseHandle $ handledHandle pstderr + , cwd = Just (nodeDir seiNode) + , env = Just [] + } + return phandle + + mapM_ closeIfRequested [ pstdin, pstdout, pstderr ] + liftIO (waitForProcess phandle) >>= \case + ExitSuccess -> return () + status -> do + outLine OutputChildFail (Just $ textProcName seiProcName) $ "failed at: " <> textSourceLine cmdSourceLine + liftIO $ putMVar seiStatusVar status + throwError Failed executePipeline :: ShellExecInfo -> HandleHandling -> HandleHandling -> HandleHandling -> ShellPipeline -> TestRun () executePipeline sei pstdin pstdout pstderr ShellPipeline {..} = do |