summaryrefslogtreecommitdiff
path: root/src/shell_manager.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/shell_manager.cc')
-rw-r--r--src/shell_manager.cc14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/shell_manager.cc b/src/shell_manager.cc
index cb6e94c7..f35b3ddc 100644
--- a/src/shell_manager.cc
+++ b/src/shell_manager.cc
@@ -16,13 +16,15 @@ ShellManager::ShellManager()
}
String ShellManager::eval(const String& cmdline, const Context& context,
+ const memoryview<String>& params,
const EnvVarMap& env_vars)
{
- return pipe("", cmdline, context, env_vars);
+ return pipe("", cmdline, context, params, env_vars);
}
String ShellManager::pipe(const String& input,
const String& cmdline, const Context& context,
+ const memoryview<String>& params,
const EnvVarMap& env_vars)
{
int write_pipe[2]; // child stdin
@@ -114,8 +116,14 @@ String ShellManager::pipe(const String& input,
++it;
}
-
- execlp("sh", "sh", "-c", cmdline.c_str(), NULL);
+ std::vector<const char*> execparams = { "sh", "-c", cmdline.c_str() };
+ if (not params.empty())
+ execparams.push_back("sh");
+ for (auto& param : params)
+ execparams.push_back(param.c_str());
+ execparams.push_back(NULL);
+
+ execvp("sh", (char* const*)execparams.data());
exit(-1);
}
catch (...) { exit(-1); }