Propagate ShellContext custom env-vars through custom commands

Fixes #1131
This commit is contained in:
Maxime Coste 2017-01-13 00:26:43 +00:00
parent 4916ea1766
commit ffc362cf9e

View File

@ -882,15 +882,16 @@ void define_command(const ParametersParser& parser, Context& context, const Shel
min = max = (size_t)str_to_int(counts); min = max = (size_t)str_to_int(counts);
desc = ParameterDesc{ {}, ParameterDesc::Flags::SwitchesAsPositional, min, max }; desc = ParameterDesc{ {}, ParameterDesc::Flags::SwitchesAsPositional, min, max };
cmd = [=](const ParametersParser& parser, Context& context, const ShellContext&) { cmd = [=](const ParametersParser& parser, Context& context, const ShellContext& sc) {
CommandManager::instance().execute(commands, context, { params_to_shell(parser) }); CommandManager::instance().execute(commands, context,
{ params_to_shell(parser), sc.env_vars });
}; };
} }
else else
{ {
desc = ParameterDesc{ {}, ParameterDesc::Flags::SwitchesAsPositional, 0, 0 }; desc = ParameterDesc{ {}, ParameterDesc::Flags::SwitchesAsPositional, 0, 0 };
cmd = [=](const ParametersParser& parser, Context& context, const ShellContext&) { cmd = [=](const ParametersParser& parser, Context& context, const ShellContext& sc) {
CommandManager::instance().execute(commands, context); CommandManager::instance().execute(commands, context, { {}, sc.env_vars });
}; };
} }