Skip to content

Commit 8e047f1

Browse files
Kai LuobzEq
Kai Luo
authored andcommitted
Refine code
1 parent 6f6d62f commit 8e047f1

File tree

1 file changed

+3
-6
lines changed
  • library/std/src/sys/unix

1 file changed

+3
-6
lines changed

library/std/src/sys/unix/os.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -497,12 +497,9 @@ pub fn current_exe() -> io::Result<PathBuf> {
497497
if let Some(p) = getenv(OsStr::from_bytes("PATH".as_bytes())) {
498498
for search_path in split_paths(&p) {
499499
let pb = search_path.join(&path);
500-
if pb.is_file() && let Ok(metadata) = crate::fs::metadata(&pb) {
501-
if metadata.permissions().mode() & 0o111 != 0 {
502-
return pb.canonicalize();
503-
}
504-
} else {
505-
continue;
500+
if pb.is_file() && let Ok(metadata) = crate::fs::metadata(&pb) &&
501+
metadata.permissions().mode() & 0o111 != 0 {
502+
return pb.canonicalize();
506503
}
507504
}
508505
}

0 commit comments

Comments
 (0)