summaryrefslogtreecommitdiff
path: root/src/Script
diff options
context:
space:
mode:
authorRoman Smrž <roman.smrz@seznam.cz>2026-08-22 22:37:53 +0200
committerRoman Smrž <roman.smrz@seznam.cz>2026-08-22 22:38:56 +0200
commit9fb76c74b5d30b592bad60de5955b9efa2e6cd65 (patch)
tree3985118032a13f5044dee357c622e3ad34d79985 /src/Script
parent0ba7a3adcc5e539a31b5893bc956a39105e6a9bf (diff)
Shell: implement ‘!’ operator
Changelog: Implement negation using the `!` operator in the shell interpreter.
Diffstat (limited to 'src/Script')
-rw-r--r--src/Script/Shell.hs12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/Script/Shell.hs b/src/Script/Shell.hs
index f070de5..dbecee3 100644
--- a/src/Script/Shell.hs
+++ b/src/Script/Shell.hs
@@ -158,7 +158,17 @@ executeCommand sei@ShellExecInfo {..} st pstdin pstdout pstderr scmd@ShellComman
executeCommandProcess :: ShellExecInfo -> ShellState -> Handle -> Handle -> Handle -> [ Text ] -> Text -> TestRun ( TestRun ProcessStatus, ShellState )
-executeCommandProcess ShellExecInfo {..} st@ShellState {..} pstdin pstdout pstderr args = \case
+executeCommandProcess sei@ShellExecInfo {..} st@ShellState {..} pstdin pstdout pstderr args = \case
+ "!"
+ | (cmd : args') <- args -> do
+ ( exit, st' ) <- executeCommandProcess sei st pstdin pstdout pstderr args' cmd
+ let exit' = exit >>= \case Exited ExitSuccess -> return (Exited (ExitFailure (-1)))
+ _ -> return (Exited ExitSuccess)
+ return ( exit', st' )
+
+ | [] <- args -> do
+ return ( return (Exited (ExitFailure (-1))), st )
+
"cd"
| [] <- args -> liftIO $ do
hPutStrLn pstdout (nodeDir seiNode)