From ffc362cf9e6448fd1d4b925e82aa26c5a47369ec Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Fri, 13 Jan 2017 00:26:43 +0000 Subject: [PATCH] Propagate ShellContext custom env-vars through custom commands Fixes #1131 --- src/commands.cc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/commands.cc b/src/commands.cc index 629bb093..e68e4cc5 100644 --- a/src/commands.cc +++ b/src/commands.cc @@ -882,15 +882,16 @@ void define_command(const ParametersParser& parser, Context& context, const Shel min = max = (size_t)str_to_int(counts); desc = ParameterDesc{ {}, ParameterDesc::Flags::SwitchesAsPositional, min, max }; - cmd = [=](const ParametersParser& parser, Context& context, const ShellContext&) { - CommandManager::instance().execute(commands, context, { params_to_shell(parser) }); + cmd = [=](const ParametersParser& parser, Context& context, const ShellContext& sc) { + CommandManager::instance().execute(commands, context, + { params_to_shell(parser), sc.env_vars }); }; } else { desc = ParameterDesc{ {}, ParameterDesc::Flags::SwitchesAsPositional, 0, 0 }; - cmd = [=](const ParametersParser& parser, Context& context, const ShellContext&) { - CommandManager::instance().execute(commands, context); + cmd = [=](const ParametersParser& parser, Context& context, const ShellContext& sc) { + CommandManager::instance().execute(commands, context, { {}, sc.env_vars }); }; }