X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fexternaltask.cpp;h=37a36d39150da641b3a39e91d5c0fb866576af02;hb=d1f9551e05c9d341149eb490e05b1465d3d6b711;hp=07ad870e6c35ec398e2885211e31fbfe890f7d28;hpb=2f55d54651622c5c3d9db2b67e9efeb141ff808d;p=builder.git diff --git a/source/externaltask.cpp b/source/externaltask.cpp index 07ad870..37a36d3 100644 --- a/source/externaltask.cpp +++ b/source/externaltask.cpp @@ -1,6 +1,4 @@ #include -#include -#include #include #include #include @@ -13,13 +11,7 @@ using namespace Msp; ExternalTask::ExternalTask(const Arguments &a, const FS::Path &wd): argv(a), - work_dir(wd), - process(0), - exit_code(-1), - stdin_action(PASSTHROUGH), - stdout_action(PASSTHROUGH), - stderr_action(PASSTHROUGH), - capture_pipe(0) + work_dir(wd) { if(argv.empty()) throw invalid_argument("ExternalTask::ExternalTask"); @@ -33,16 +25,16 @@ ExternalTask::~ExternalTask() string ExternalTask::get_command() const { string cmd; - for(vector::const_iterator i=argv.begin(); i!=argv.end(); ++i) + for(const string &a: argv) { - if(i!=argv.begin()) + if(!cmd.empty()) cmd += ' '; - for(string::const_iterator j=i->begin(); j!=i->end(); ++j) + for(char c: a) { - if(*j=='"' || *j=='\'' || *j==' ' || *j=='\\' || *j=='&') + if(c=='"' || c=='\'' || c==' ' || c=='\\' || c=='&') cmd += '\\'; - cmd += *j; + cmd += c; } } @@ -73,7 +65,11 @@ void ExternalTask::start() if(stdin_action==IGNORE || stdout_action==IGNORE || stderr_action==IGNORE) { +#ifdef _WIN32 + devnull = new IO::File("nul", IO::M_RDWR); +#else devnull = new IO::File("/dev/null", IO::M_RDWR); +#endif if(stdin_action==IGNORE) process->redirect_cin(*devnull); if(stdout_action==IGNORE)