Skip to content

Commit

Permalink
Don't wastefully execute everything via a shell
Browse files Browse the repository at this point in the history
We should only ever use the shell if we want to use the shell's
features, such as pipes, non-trivial redirection, or shell language
features (branches/loops/etc.).  Otherwise, executing a program via
the shell is pointless and wasteful.
  • Loading branch information
CyberShadow committed Jul 20, 2023
1 parent 3cc17fc commit 0eeed18
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions source/dub/compilers/compiler.d
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,12 @@ interface Compiler {

int status;
if (output_callback) {
auto result = executeShell(escapeShellCommand(args),
auto result = execute(args,
env, Config.none, size_t.max, cwd.toNativeString());
output_callback(result.status, result.output);
status = result.status;
} else {
auto compiler_pid = spawnShell(escapeShellCommand(args),
auto compiler_pid = spawnProcess(args,
env, Config.none, cwd.toNativeString());
status = compiler_pid.wait();
}
Expand Down Expand Up @@ -185,7 +185,7 @@ interface Compiler {

auto fil = generatePlatformProbeFile();

auto result = executeShell(escapeShellCommand(compiler_binary ~ args ~ fil.toNativeString()));
auto result = execute(compiler_binary ~ args ~ fil.toNativeString());
enforce!CompilerInvocationException(result.status == 0,
format("Failed to invoke the compiler %s to determine the build platform: %s",
compiler_binary, result.output));
Expand Down
2 changes: 1 addition & 1 deletion source/dub/internal/git.d
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ private string determineVersionWithGitTool(NativePath path)
auto git_dir_param = "--git-dir=" ~ git_dir.toNativeString();

static string exec(scope string[] params...) {
auto ret = executeShell(escapeShellCommand(params));
auto ret = execute(params);
if (ret.status == 0) return ret.output.strip;
logDebug("'%s' failed with exit code %s: %s", params.join(" "), ret.status, ret.output.strip);
return null;
Expand Down

0 comments on commit 0eeed18

Please sign in to comment.