From 1204839cc27af071582b8f6c88530b6840f56f72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Sat, 22 Aug 2026 20:07:18 +0200 Subject: Shell: implement pwd command Changelog: Implemented `pwd` command in shell interpreter. --- src/Script/Shell.hs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/Script') diff --git a/src/Script/Shell.hs b/src/Script/Shell.hs index 91bdcb0..fbb92af 100644 --- a/src/Script/Shell.hs +++ b/src/Script/Shell.hs @@ -154,6 +154,13 @@ 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 + "pwd" + | [] <- args -> do + liftIO $ hPutStrLn pstdout shellWorkingDirectory + return ( return (Exited ExitSuccess), st ) + | otherwise -> do + liftIO $ hPutStrLn pstderr $ "pwd: too many arguments" + return ( return (Exited (ExitFailure (-1))), st ) cmd -> liftIO $ do (_, _, _, phandle) <- createProcess_ "shell" (proc (T.unpack cmd) (map T.unpack args)) -- cgit v1.2.3