Skip to content

Commit

Permalink
Optimize get_current_dir
Browse files Browse the repository at this point in the history
Closes: #628
  • Loading branch information
sayanarijit committed Jul 7, 2023
1 parent f440b56 commit f3a2d51
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,14 @@ pub fn get_tty() -> Result<fs::File> {
// returns physical path. As a workaround, this function tries to use `PWD`
// environment variable that is configured by shell.
fn get_current_dir() -> Result<PathBuf, std::io::Error> {
let cur = std::env::current_dir();
if let Ok(pwd) = std::env::var("PWD") {
if pwd.is_empty() {
cur
std::env::current_dir()
} else {
Ok(PathBuf::from(pwd))
}
} else {
cur
std::env::current_dir()
}
}

Expand Down

0 comments on commit f3a2d51

Please sign in to comment.