Skip to content

Commit 9fff0f8

Browse files
committed
cli(run): avoid duplicate runtime error message
Propagate negative exit code from script runner as 'already handled' to suppress generic error output, while preserving real exit status.
1 parent fe223af commit 9fff0f8

File tree

4 files changed

+28
-4
lines changed

4 files changed

+28
-4
lines changed

include/vix/cli/commands/run/RunDetail.hpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,12 @@ namespace vix::commands::RunCommand::detail
7676
std::string badDoubleDashArg;
7777
};
7878

79+
struct ScriptRunResult
80+
{
81+
int code = 0;
82+
bool handled = false;
83+
};
84+
7985
// Process / IO
8086
int run_cmd_live_filtered(
8187
const std::string &cmd,
@@ -91,6 +97,9 @@ namespace vix::commands::RunCommand::detail
9197
if (code < 0)
9298
return 1;
9399

100+
if (code <= 255)
101+
return code;
102+
94103
if (WIFEXITED(code))
95104
return WEXITSTATUS(code);
96105

src/commands/RunCommand.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,12 @@ namespace vix::commands::RunCommand
301301

302302
if (opt.singleCpp)
303303
{
304-
return detail::run_single_cpp(opt);
304+
int rc = detail::run_single_cpp(opt);
305+
306+
if (rc < 0)
307+
return -rc;
308+
309+
return rc;
305310
}
306311

307312
// 2) Mode projet (apps)

src/commands/run/RunProcess.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,9 @@ namespace vix::commands::RunCommand::detail
559559

560560
if (::pipe(outPipe) != 0)
561561
{
562-
result.exitCode = std::system(cmd.c_str());
562+
const int st = std::system(cmd.c_str());
563+
result.rawStatus = st;
564+
result.exitCode = normalize_exit_code(st);
563565
return result;
564566
}
565567

@@ -569,7 +571,9 @@ namespace vix::commands::RunCommand::detail
569571
close_safe(outPipe[0]);
570572
close_safe(outPipe[1]);
571573

572-
result.exitCode = std::system(cmd.c_str());
574+
const int st = std::system(cmd.c_str());
575+
result.rawStatus = st;
576+
result.exitCode = normalize_exit_code(st);
573577
return result;
574578
}
575579

src/commands/run/RunScript.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,13 @@ namespace vix::commands::RunCommand::detail
507507
}
508508
}
509509

510-
handle_runtime_exit_code(runCode, "Script execution failed", /*alreadyHandled=*/handled);
510+
const bool already = handled || rr.printed_live;
511+
512+
handle_runtime_exit_code(runCode, "Script execution failed", /*alreadyHandled=*/already);
513+
514+
if (already && runCode > 0 && runCode != 130)
515+
return -runCode;
516+
511517
return runCode;
512518
}
513519

0 commit comments

Comments
 (0)