@@ -4,34 +4,34 @@ import mcl.utils.test;
44
55import mcl.utils.tui : bold;
66
7- import std.process : ProcessPipes;
7+ import std.process : ProcessPipes, Redirect ;
88import std.string : split, strip;
99import core.sys.posix.unistd : geteuid;
1010import std.json : JSONValue, parseJSON;
1111
1212bool isRoot () => geteuid() == 0 ;
1313
14- T execute (T = string )(string args, bool printCommand = true , bool returnErr = false ) if (is (T == string ) || is (T == ProcessPipes) || is (T == JSONValue))
14+ T execute (T = string )(string args, bool printCommand = true , bool returnErr = false , Redirect redirect = Redirect.all ) if (is (T == string ) || is (T == ProcessPipes) || is (T == JSONValue))
1515{
16- return execute! T(args.split(" " ), printCommand, returnErr);
16+ return execute! T(args.strip. split(" " ), printCommand, returnErr, redirect );
1717}
18- T execute (T = string )(string [] args, bool printCommand = true , bool returnErr = false ) if (is (T == string ) || is (T == ProcessPipes) || is (T == JSONValue))
18+ T execute (T = string )(string [] args, bool printCommand = true , bool returnErr = false , Redirect redirect = Redirect.all ) if (is (T == string ) || is (T == ProcessPipes) || is (T == JSONValue))
1919{
2020 import std.exception : enforce;
2121 import std.format : format;
22- import std.process : pipeShell, wait, Redirect, escapeShellCommand;
22+ import std.process : pipeShell, wait, escapeShellCommand;
2323 import std.logger : tracef, errorf, infof;
2424 import std.array : join;
25- import std.algorithm : map;
25+ import std.algorithm : map, canFind ;
2626 import std.conv : to;
2727
28- auto cmd = args.map! escapeShellCommand.join(" " );
28+ auto cmd = args.map! (x => x.canFind( " * " ) ? x : x. escapeShellCommand()) .join(" " );
2929
3030 if (printCommand)
3131 {
3232 infof(" \n $ `%s`" , cmd.bold);
3333 }
34- auto res = pipeShell(cmd, Redirect.all );
34+ auto res = pipeShell(cmd, redirect );
3535 static if (is (T == ProcessPipes))
3636 {
3737 return res;
0 commit comments