launch::popen respects dry run flag (#27)

This commit is contained in:
Nicholas O'Connor 2017-07-05 14:19:39 -07:00
parent e735768e52
commit 96ccab40f7

View File

@ -6,6 +6,7 @@
#include <boost/algorithm/string.hpp> #include <boost/algorithm/string.hpp>
#include "subprocess.hpp" #include "subprocess.hpp"
#include "cellar.hpp"
#include "bottles.hpp" #include "bottles.hpp"
#include "launch.hpp" #include "launch.hpp"
#include "internal/launch.hpp" #include "internal/launch.hpp"
@ -48,12 +49,14 @@ void cellar::launch::popen(string argv) {
void cellar::launch::popen(vector<string> argv) { void cellar::launch::popen(vector<string> argv) {
output::statement("launching program: " + boost::algorithm::join(argv, " "), true); output::statement("launching program: " + boost::algorithm::join(argv, " "), true);
string exec = argv[0]; if (!dryrun) {
vector<string> subargv; string exec = argv[0];
for (int curarg = 1; curarg < argv.size(); curarg++) { vector<string> subargv;
subargv.push_back(argv[curarg]); for (int curarg = 1; curarg < argv.size(); curarg++) {
subargv.push_back(argv[curarg]);
}
auto subproc = subprocess::popen(exec, subargv);
cout << subproc.stdout().rdbuf();
cerr << subproc.stderr().rdbuf();
} }
auto subproc = subprocess::popen(exec, subargv);
cout << subproc.stdout().rdbuf();
cerr << subproc.stderr().rdbuf();
} }