File tree Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Original file line number Diff line number Diff line change @@ -381,15 +381,16 @@ int swift::mainEntry(int argc_, const char **argv_) {
381
381
subCommandArgs.erase (&subCommandArgs[1 ]);
382
382
// We are running as a subcommand, try to find the subcommand adjacent to
383
383
// the executable we are running as.
384
- SmallString<256 > SubcommandPath (
385
- llvm::sys::path::parent_path (getExecutablePath (argv[0 ])));
386
- llvm::sys::path::append (SubcommandPath, SubcommandName);
387
-
388
- // If we didn't find the tool there, let the OS search for it.
389
- if (!llvm::sys::fs::exists (SubcommandPath)) {
384
+ SmallString<256 > SubcommandPath (SubcommandName);
385
+ auto result = llvm::sys::findProgramByName (SubcommandName,
386
+ { llvm::sys::path::parent_path (getExecutablePath (argv[0 ])) });
387
+ if (!result.getError ()) {
388
+ SubcommandPath = *result;
389
+ } else {
390
+ // If we didn't find the tool there, let the OS search for it.
391
+ result = llvm::sys::findProgramByName (SubcommandName);
390
392
// Search for the program and use the path if found. If there was an
391
393
// error, ignore it and just let the exec fail.
392
- auto result = llvm::sys::findProgramByName (SubcommandName);
393
394
if (!result.getError ())
394
395
SubcommandPath = *result;
395
396
}
You can’t perform that action at this time.
0 commit comments