the shell used for command execution can be changed using the 'shell' option

This commit is contained in:
Maxime Coste 2012-12-10 18:41:01 +01:00
parent 33f87db553
commit 9230ccc087
2 changed files with 6 additions and 3 deletions

View File

@ -97,6 +97,7 @@ GlobalOptions::GlobalOptions()
set_option("indentwidth", Option(4)); set_option("indentwidth", Option(4));
set_option("eolformat", Option("lf")); set_option("eolformat", Option("lf"));
set_option("BOM", Option("no")); set_option("BOM", Option("no"));
set_option("shell", Option("sh"));
set_option("complete_prefix", Option(1)); set_option("complete_prefix", Option(1));
set_option("ignored_files", Option(R"(^(\..*|.*\.(o|so|a))$)")); set_option("ignored_files", Option(R"(^(\..*|.*\.(o|so|a))$)"));
} }

View File

@ -1,6 +1,7 @@
#include "shell_manager.hh" #include "shell_manager.hh"
#include "debug.hh" #include "debug.hh"
#include "context.hh"
#include <cstring> #include <cstring>
#include <sys/types.h> #include <sys/types.h>
@ -116,14 +117,15 @@ String ShellManager::pipe(const String& input,
++it; ++it;
} }
std::vector<const char*> execparams = { "sh", "-c", cmdline.c_str() }; String shell = context.options()["shell"].as_string();
std::vector<const char*> execparams = { shell.c_str(), "-c", cmdline.c_str() };
if (not params.empty()) if (not params.empty())
execparams.push_back("sh"); execparams.push_back(shell.c_str());
for (auto& param : params) for (auto& param : params)
execparams.push_back(param.c_str()); execparams.push_back(param.c_str());
execparams.push_back(NULL); execparams.push_back(NULL);
execvp("sh", (char* const*)execparams.data()); execvp(shell.c_str(), (char* const*)execparams.data());
exit(-1); exit(-1);
} }
catch (...) { exit(-1); } catch (...) { exit(-1); }