-
Notifications
You must be signed in to change notification settings - Fork 220
Closed
Description
When executing a command such as:
host.exec('grep', ['"[\""', 'file.txt']);If grep encounters a syntax error or similar issue, it exits with code 2. However, in nodehost.ts
genaiscript/packages/cli/src/nodehost.ts
Lines 614 to 626 in bc4456d
| if (!ignoreError) { | |
| trace?.error("exec failed", err) | |
| } | |
| return { | |
| stdout: "", | |
| stderr: errorMessage(err), | |
| exitCode: 1, | |
| failed: true, | |
| } | |
| } finally { | |
| trace?.endDetails() | |
| } | |
| } |
genaiscript catches the error and override the original exit code, returning 1 instead.
This behavior masks the real exit status of the executed process, making it impossible to distinguish between different failure modes—e.g., grep returning 1 for "no matches found" versus 2 for an error.
Expected Behavior
host.exec should preserve and propagate the actual exit code of the subprocess so that consumers can handle different exit codes correctly.
Copilot
Metadata
Metadata
Assignees
Labels
No labels