15#include <util/pragma_push.def>
17#pragma warning(disable:4668)
19#pragma warning(disable:5039)
24#include <util/pragma_pop.def>
48int run(
const std::string &what,
const std::vector<std::string> &argv)
50 return run(what, argv,
"",
"",
"");
48int run(
const std::string &what,
const std::vector<std::string> &argv) {
…}
55#define STDOUT_FILENO 1
56#define STDERR_FILENO 2
125 perror((
"Failed to open " + name +
" file " + file).c_str());
132 int flags = 0, mode = 0;
156 perror((
"Failed to open " + name +
" file " + file).c_str());
168 if(src.find_first_of(
L" \t\n\v\"") == src.npos && !src.empty())
171 std::wstring result =
L"\"";
173 for(
auto it = src.begin();; ++it)
177 while(it != src.end() && *it ==
L'\\')
202 result.push_back(*it);
211 result.push_back(*it);
215 result.push_back(
L'"');
253 const std::string &what,
254 const std::vector<std::string> &argv,
261 std::wstring cmdline;
266 for(std::size_t i = 1; i < argv.size(); i++)
371 std::vector<char *>
_argv(argv.size()+1);
372 for(std::size_t i=0; i<argv.size(); i++)
375 _argv[argv.size()]=
nullptr;
388 perror(std::string(
"execvp "+what+
" failed").c_str());
410 perror(
"Waiting for child process failed");
456 if(src.find(
' ')==std::string::npos &&
457 src.find(
'"')==std::string::npos &&
458 src.find(
'&')==std::string::npos &&
459 src.find(
'|')==std::string::npos &&
460 src.find(
'(')==std::string::npos &&
461 src.find(
')')==std::string::npos &&
462 src.find(
'<')==std::string::npos &&
463 src.find(
'>')==std::string::npos &&
464 src.find(
'^')==std::string::npos)
474 for(
const char ch : src)
489 if(src.find(
' ')==std::string::npos &&
490 src.find(
'"')==std::string::npos &&
491 src.find(
'*')==std::string::npos &&
492 src.find(
'$')==std::string::npos &&
493 src.find(
'\\')==std::string::npos &&
494 src.find(
'?')==std::string::npos &&
495 src.find(
'&')==std::string::npos &&
496 src.find(
'|')==std::string::npos &&
497 src.find(
'>')==std::string::npos &&
498 src.find(
'<')==std::string::npos &&
499 src.find(
'^')==std::string::npos &&
500 src.find(
'\'')==std::string::npos)
511 for(
const char ch : src)
525 const std::string &what,
526 const std::vector<std::string> &argv,
548 for(
const auto &arg : argv)
ait supplies three of the four components needed: an abstract interpreter (in this case handling func...
int open(const char *pathname, int flags,...)
output_type narrow(input_type input)
Run-time checked narrowing cast.
int run(const std::string &what, const std::vector< std::string > &argv)
static fdt stdio_redirection(int fd, const std::string &file)
open given file to replace either stdin, stderr, stdout
std::string shell_quote(const std::string &src)
quote a string for bash and CMD
void remove_signal_catcher()
void register_child(pid_t pid)
#define UNREACHABLE
This should be used to mark dead code.
void perror(const char *s)
char * strdup(const char *str)
std::wstring widen(const char *s)