Skip to content

Commit 6305d89

Browse files
fix: capture appends a program's standard error read from its own pipe
Co-authored-by: speak-agent <248744407+speak-agent@users.noreply.github.com>
1 parent 8d0afd7 commit 6305d89

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

‎src/tool.cppm‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ inline std::string describe_missing(const spec& s, const found& f) {
350350
// --show-sdk-path`, a compiler's version, a dry run's plan -- through
351351
// mcpplibs.os: the program and its arguments as a vector, with no shell between,
352352
// so nothing is quoted and no null device is named on any host. The standard
353-
// error is dropped, or merged into the output when `with_errors`. A program that
353+
// error is dropped, or appended to the output when `with_errors`. A program that
354354
// does not end within a minute is ended; `status` is then the shell's code for
355355
// it, and -1 when the program could not be started at all.
356356
struct printed {
@@ -367,9 +367,11 @@ inline printed capture(const std::vector<std::string>& argv, bool with_errors =
367367
o.args.assign(argv.begin() + 1, argv.end());
368368
o.cwd = cwd;
369369
o.in = process::stdio::null;
370-
o.err = with_errors ? process::stdio::output : process::stdio::null;
370+
o.err = with_errors ? process::stdio::pipe : process::stdio::null;
371371
auto r = process::run(std::move(o), process::bounds{});
372372
if (!r) return {};
373+
// The standard error after the output, as a reader of either finds it.
374+
if (with_errors) r->out += r->err;
373375
return {r->status.shell_code(), std::move(r->out)};
374376
}
375377

0 commit comments

Comments
 (0)