diff --git a/crates/nu-engine/src/eval.rs b/crates/nu-engine/src/eval.rs index 000f879f8..d5353615e 100644 --- a/crates/nu-engine/src/eval.rs +++ b/crates/nu-engine/src/eval.rs @@ -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,