X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fexternaltask.cpp;h=33ffcebc4622889eaed085e371cc19fbb8a348df;hb=302977793935e100a5bf37822836531cafb03bf3;hp=f7ab199b417121712ef3d9a408a58565cc6961d8;hpb=a5a1ecb806ec2dec26701b931b8d2d6cbe7f4928;p=builder.git diff --git a/source/externaltask.cpp b/source/externaltask.cpp index f7ab199..33ffceb 100644 --- a/source/externaltask.cpp +++ b/source/externaltask.cpp @@ -1,6 +1,4 @@ #include -#include -#include #include #include #include @@ -33,16 +31,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 +71,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) @@ -130,7 +132,7 @@ Task::Status ExternalTask::do_wait(bool block) { while(process) { - if(process->wait(!capture_pipe)) + if(process->wait(block && !capture_pipe)) { exit_code = process->get_exit_code(); delete process;