mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 02:24:58 +02:00
Keep the environment properly set. (#3072)
* Revert "fix prompts on startup (#3056)"
This reverts commit b202951c1d
.
* Ensure environment variables synced with global internal Nu Scope.
This commit is contained in:
committed by
GitHub
parent
892aae267d
commit
08e7d0dfb6
@ -176,8 +176,7 @@ impl Scope {
|
||||
|
||||
pub fn add_env_var(&self, name: impl Into<String>, value: String) {
|
||||
if let Some(frame) = self.frames.lock().last_mut() {
|
||||
let name = name.into();
|
||||
frame.env.insert(name, value);
|
||||
frame.env.insert(name.into(), value);
|
||||
}
|
||||
}
|
||||
|
||||
@ -192,6 +191,12 @@ impl Scope {
|
||||
frame.env.extend(env_vars)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn add_env_var_to_base(&self, name: impl Into<String>, value: String) {
|
||||
if let Some(frame) = self.frames.lock().first_mut() {
|
||||
frame.env.insert(name.into(), value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl ParserScope for Scope {
|
||||
|
@ -21,10 +21,11 @@ pub fn nu(env: &IndexMap<String, String>, tag: impl Into<Tag>) -> Result<Value,
|
||||
nu_dict.insert_value("config", UntaggedValue::row(config).into_value(&tag));
|
||||
|
||||
let mut table = vec![];
|
||||
let path = std::env::var_os("PATH");
|
||||
if let Some(paths) = path {
|
||||
for path in std::env::split_paths(&paths) {
|
||||
table.push(UntaggedValue::filepath(path).into_value(&tag));
|
||||
for v in env.iter() {
|
||||
if v.0 == "PATH" || v.0 == "Path" {
|
||||
for path in std::env::split_paths(&v.1) {
|
||||
table.push(UntaggedValue::filepath(path).into_value(&tag));
|
||||
}
|
||||
}
|
||||
}
|
||||
nu_dict.insert_value("path", UntaggedValue::table(&table).into_value(&tag));
|
||||
|
Reference in New Issue
Block a user