Skip to content

host.exec rewrites exit value of spawned process to 1 #1833

@lemmy

Description

@lemmy

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

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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions