Skip to content

Commit 313c61d

Browse files
committed
Optimize get_current_dir
Closes: sayanarijit#628
1 parent 255517c commit 313c61d

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/runner.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,14 @@ pub fn get_tty() -> Result<fs::File> {
4040
// returns physical path. As a workaround, this function tries to use `PWD`
4141
// environment variable that is configured by shell.
4242
fn get_current_dir() -> Result<PathBuf, std::io::Error> {
43-
let cur = std::env::current_dir();
4443
if let Ok(pwd) = std::env::var("PWD") {
4544
if pwd.is_empty() {
46-
cur
45+
std::env::current_dir()
4746
} else {
4847
Ok(PathBuf::from(pwd))
4948
}
5049
} else {
51-
cur
50+
std::env::current_dir()
5251
}
5352
}
5453

0 commit comments

Comments
 (0)