From 11304f00cfab0a0e2249c2fcf54f40177e21b1aa Mon Sep 17 00:00:00 2001 From: Fabian Boehm Date: Fri, 6 Oct 2023 18:15:25 +0200 Subject: [PATCH] Apply variable overrides for exec Fixes #9995 (cherry picked from commit 496d65fb5d9660f2f0287a7c3951f96324f04de8) --- src/exec.cpp | 5 +++++ tests/checks/exec.fish | 8 ++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/exec.cpp b/src/exec.cpp index 7fae21c3d..26809c80c 100644 --- a/src/exec.cpp +++ b/src/exec.cpp @@ -1006,6 +1006,11 @@ bool exec_job(parser_t &parser, const shared_ptr &j, const io_chain_t &bl return false; } + // Apply foo=bar variable assignments + for (const auto &assignment : j->processes.front()->variable_assignments) { + parser.vars().set(assignment.variable_name, ENV_LOCAL | ENV_EXPORT, assignment.values); + } + internal_exec(parser.vars(), j.get(), block_io); // internal_exec only returns if it failed to set up redirections. // In case of an successful exec, this code is not reached. diff --git a/tests/checks/exec.fish b/tests/checks/exec.fish index ddaa203a6..ed7d8d5a2 100644 --- a/tests/checks/exec.fish +++ b/tests/checks/exec.fish @@ -1,4 +1,5 @@ -#RUN: %fish %s +#RUN: %fish -C 'set -l fish %fish' %s + exec cat