Code style change in shell_manager.cc

This commit is contained in:
Maxime Coste 2015-03-13 13:25:20 +00:00
parent 2747c4dd3e
commit dbe27d3df2

View File

@ -99,31 +99,25 @@ String ShellManager::pipe(StringView input,
dup2(error_pipe[1], 2); close(error_pipe[1]); dup2(error_pipe[1], 2); close(error_pipe[1]);
dup2(write_pipe[0], 0); close(write_pipe[0]); dup2(write_pipe[0], 0); close(write_pipe[0]);
RegexIterator<StringView::iterator> it(cmdline.begin(), cmdline.end(), env_var_regex); using RegexIt = RegexIterator<StringView::iterator>;
RegexIterator<StringView::iterator> end; for (RegexIt it{cmdline.begin(), cmdline.end(), env_var_regex}, end;
it != end; ++it)
while (it != end)
{ {
auto& match = *it; auto& match = *it;
StringView name = StringView(match[1].first, match[1].second); StringView name{match[1].first, match[1].second};
kak_assert(name.length() > 0); kak_assert(name.length() > 0);
auto local_var = env_vars.find(name.str()); auto local_var = env_vars.find(name.str());
if (local_var != env_vars.end()) if (local_var != env_vars.end())
setenv(("kak_" + name).c_str(), local_var->second.c_str(), 1); setenv(("kak_" + name).c_str(), local_var->second.c_str(), 1);
else else try
{
try
{ {
String value = get_val(name, context); String value = get_val(name, context);
setenv(("kak_"_str + name).c_str(), value.c_str(), 1); setenv(("kak_"_str + name).c_str(), value.c_str(), 1);
} }
catch (runtime_error&) {} catch (runtime_error&) {}
} }
++it;
}
const char* shell = "/bin/sh"; const char* shell = "/bin/sh";
auto cmdlinezstr = cmdline.zstr(); auto cmdlinezstr = cmdline.zstr();
Vector<const char*> execparams = { shell, "-c", cmdlinezstr }; Vector<const char*> execparams = { shell, "-c", cmdlinezstr };