mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-25 06:41:15 -03:00
add $pipestatus support
This commit is contained in:
12
src/exec.cpp
12
src/exec.cpp
@@ -824,6 +824,7 @@ static bool exec_block_or_func_process(parser_t &parser, std::shared_ptr<job_t>
|
||||
}
|
||||
|
||||
int status = proc_get_last_status();
|
||||
p->status = status;
|
||||
|
||||
// If we have a block output buffer, populate it now.
|
||||
if (!block_output_bufferfill) {
|
||||
@@ -1056,6 +1057,7 @@ bool exec_job(parser_t &parser, shared_ptr<job_t> j) {
|
||||
}
|
||||
|
||||
j->continue_job(false);
|
||||
proc_set_last_job_statuses(*j);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1064,6 +1066,7 @@ static int exec_subshell_internal(const wcstring &cmd, parser_t &parser, wcstrin
|
||||
ASSERT_IS_MAIN_THREAD();
|
||||
bool prev_subshell = is_subshell;
|
||||
const int prev_status = proc_get_last_status();
|
||||
const auto& prev_job_statuses = proc_get_last_job_statuses();
|
||||
bool split_output = false;
|
||||
|
||||
const auto ifs = parser.vars().get(L"IFS");
|
||||
@@ -1090,7 +1093,14 @@ static int exec_subshell_internal(const wcstring &cmd, parser_t &parser, wcstrin
|
||||
|
||||
// If the caller asked us to preserve the exit status, restore the old status. Otherwise set the
|
||||
// status of the subcommand.
|
||||
proc_set_last_status(apply_exit_status ? subcommand_status : prev_status);
|
||||
if (apply_exit_status) {
|
||||
proc_set_last_status(subcommand_status);
|
||||
}
|
||||
else {
|
||||
proc_set_last_job_statuses(std::move(prev_job_statuses));
|
||||
proc_set_last_status(prev_status);
|
||||
}
|
||||
|
||||
is_subshell = prev_subshell;
|
||||
|
||||
if (lst == NULL || !buffer) {
|
||||
|
||||
Reference in New Issue
Block a user