Skip to content

Commit e776ff0

Browse files
committed
Return appropriate error if path list defined and empty
1 parent 70d2d1c commit e776ff0

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/finder.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,12 @@ impl Finder {
8383
}
8484
_ => {
8585
// Search binary in PATHs(defined in environment variable).
86-
let p = paths.ok_or(Error::CannotGetCurrentDirAndPathListEmpty)?;
87-
let paths: Vec<_> = env::split_paths(&p).collect();
86+
let paths =
87+
env::split_paths(&paths.ok_or(Error::CannotGetCurrentDirAndPathListEmpty)?)
88+
.collect::<Vec<_>>();
89+
if paths.is_empty() {
90+
return Err(Error::CannotGetCurrentDirAndPathListEmpty);
91+
}
8892

8993
Either::Right(Self::path_search_candidates(path, paths).into_iter())
9094
}

0 commit comments

Comments
 (0)