mirror of
https://github.com/nushell/nushell
synced 2025-01-13 21:55:07 +00:00
parent
626b1b99cd
commit
c2aa6c708d
1 changed files with 12 additions and 5 deletions
|
@ -530,6 +530,18 @@ pub fn eval_variable(
|
|||
}
|
||||
}
|
||||
|
||||
// since the env var PWD doesn't exist on all platforms
|
||||
// lets just get the current directory
|
||||
if let Ok(current_dir) = std::env::current_dir() {
|
||||
if let Some(cwd) = current_dir.to_str() {
|
||||
output_cols.push("cwd".into());
|
||||
output_vals.push(Value::String {
|
||||
val: cwd.into(),
|
||||
span,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(home_path) = nu_path::home_dir() {
|
||||
if let Some(home_path_str) = home_path.to_str() {
|
||||
output_cols.push("home-path".into());
|
||||
|
@ -540,11 +552,6 @@ pub fn eval_variable(
|
|||
}
|
||||
}
|
||||
|
||||
if let Ok(cwd) = std::env::var("PWD") {
|
||||
output_cols.push("pwd".into());
|
||||
output_vals.push(Value::String { val: cwd, span })
|
||||
}
|
||||
|
||||
Ok(Value::Record {
|
||||
cols: output_cols,
|
||||
vals: output_vals,
|
||||
|
|
Loading…
Reference in a new issue