Only warn on exec for background jobs

If it's a foreground job, it is related to the currently running exec.

This fixes exec in functions, i.e.

    function reload
        exec fish
    end

would previously always ask about the "function reload" job.

Fixes #5449.

Fixes oh-my-fish/oh-my-fish#664.
This commit is contained in:
Fabian Homborg 2018-12-30 22:32:07 +01:00
parent e33d29a5d8
commit b0072482e4

View File

@ -773,7 +773,10 @@ parse_execution_result_t parse_execution_context_t::populate_plain_process(
bool have_bg = false;
const job_t *bg = nullptr;
while ((bg = jobs.next())) {
if (!bg->is_completed()) {
// The assumption here is that if it is a foreground job,
// it's related to us.
// This stops us from asking if we're doing `exec` inside a function.
if (!bg->is_completed() && !bg->is_foreground()) {
have_bg = true;
break;
}