summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlcan <[email protected]>2025-05-21 09:00:54 -0700
committerGitHub <[email protected]>2025-05-21 09:00:54 -0700
commit8a70b98d1dd492c645b828a2e180a66e1c20d5cd (patch)
treeb400288afd444d930d1b3d4ae878bd5c83bba245
parentc9de822930dff0a4bbd3ee5e13023b54dc0222c3 (diff)
fix exit code for shell mode also (#466)
-rw-r--r--packages/cli/src/ui/hooks/shellCommandProcessor.test.ts4
-rw-r--r--packages/cli/src/ui/hooks/shellCommandProcessor.ts2
2 files changed, 3 insertions, 3 deletions
diff --git a/packages/cli/src/ui/hooks/shellCommandProcessor.test.ts b/packages/cli/src/ui/hooks/shellCommandProcessor.test.ts
index 6d7ea5d6..3645cc80 100644
--- a/packages/cli/src/ui/hooks/shellCommandProcessor.test.ts
+++ b/packages/cli/src/ui/hooks/shellCommandProcessor.test.ts
@@ -155,7 +155,7 @@ describe('useShellCommandProcessor', () => {
expect.stringContaining('Executing shell command in /current/dir:'),
);
expect(mockExecuteCommand).toHaveBeenCalledWith(
- '{ !ls -l; }; pwd >/tmp/shell_pwd_randomBytes.tmp',
+ '{ !ls -l; }; __code=$?; pwd >/tmp/shell_pwd_randomBytes.tmp; exit $__code',
{ cwd: '/current/dir' },
expect.any(Function),
);
@@ -272,7 +272,7 @@ describe('useShellCommandProcessor', () => {
expect.any(Number),
);
expect(mockExecuteCommand).toHaveBeenCalledWith(
- '{ !sleep 5 & }; pwd >/tmp/shell_pwd_randomBytes.tmp',
+ '{ !sleep 5 & }; __code=$?; pwd >/tmp/shell_pwd_randomBytes.tmp; exit $__code',
{ cwd: '/current/dir' },
expect.any(Function),
);
diff --git a/packages/cli/src/ui/hooks/shellCommandProcessor.ts b/packages/cli/src/ui/hooks/shellCommandProcessor.ts
index 35935e7d..ae8367d6 100644
--- a/packages/cli/src/ui/hooks/shellCommandProcessor.ts
+++ b/packages/cli/src/ui/hooks/shellCommandProcessor.ts
@@ -43,7 +43,7 @@ export const useShellCommandProcessor = (
const pwdFilePath = path.join(os.tmpdir(), pwdFileName);
if (!commandToExecute.endsWith('&')) commandToExecute += ';';
// note here we could also restore a previous pwd with `cd {cwd}; { ... }`
- commandToExecute = `{ ${commandToExecute} }; pwd >${pwdFilePath}`;
+ commandToExecute = `{ ${commandToExecute} }; __code=$?; pwd >${pwdFilePath}; exit $__code`;
const userMessageTimestamp = Date.now();
addItemToHistory(