Ready for testing
This commit is contained in:
parent
b6a7f56a1e
commit
542d7ac2a1
3
crates/nu-cli/src/env/TODO.org
vendored
3
crates/nu-cli/src/env/TODO.org
vendored
|
@ -21,3 +21,6 @@ returning =None=, which completely skips running the code for dealing with direc
|
||||||
** Security
|
** Security
|
||||||
https://github.com/nushell/nushell/issues/1965
|
https://github.com/nushell/nushell/issues/1965
|
||||||
** Nice errors
|
** Nice errors
|
||||||
|
** Potential issues
|
||||||
|
- Currently the functionality to restore environment variables is disabled, as it is handled by other parts of nushell just fine.
|
||||||
|
- This functionality might need to be re-added if
|
|
@ -1,10 +1,8 @@
|
||||||
use indexmap::{IndexMap, IndexSet};
|
use indexmap::{IndexMap, IndexSet};
|
||||||
use nu_protocol::{Primitive, UntaggedValue, Value};
|
use nu_protocol::{Primitive, UntaggedValue, Value};
|
||||||
use std::io::Write;
|
|
||||||
use std::{
|
use std::{
|
||||||
ffi::OsString,
|
ffi::OsString,
|
||||||
fmt::Debug,
|
fmt::Debug,
|
||||||
fs::OpenOptions,
|
|
||||||
io::{Error, ErrorKind, Result},
|
io::{Error, ErrorKind, Result},
|
||||||
path::PathBuf,
|
path::PathBuf,
|
||||||
};
|
};
|
||||||
|
@ -108,25 +106,23 @@ impl DirectorySpecificEnvironment {
|
||||||
//If we are about to overwrite any environment variables, we save them first so they can be restored later.
|
//If we are about to overwrite any environment variables, we save them first so they can be restored later.
|
||||||
if let Some(existing_val) = std::env::var_os(dir_env_key) {
|
if let Some(existing_val) = std::env::var_os(dir_env_key) {
|
||||||
if !seen_vars.contains(dir_env_key) {
|
if !seen_vars.contains(dir_env_key) {
|
||||||
// self.overwritten_env_vars
|
self.overwritten_env_vars
|
||||||
// .entry(wdir.to_path_buf())
|
.entry(wdir.to_path_buf())
|
||||||
// .or_insert(IndexMap::new())
|
.or_insert(IndexMap::new())
|
||||||
// .insert(dir_env_key.clone(), existing_val);
|
.insert(dir_env_key.clone(), existing_val);
|
||||||
|
|
||||||
std::env::set_var(dir_env_key, dir_env_val.clone());
|
|
||||||
seen_vars.insert(dir_env_key.clone());
|
seen_vars.insert(dir_env_key.clone());
|
||||||
vars_to_add.insert(dir_env_key.clone(), dir_env_val);
|
vars_to_add.insert(dir_env_key.clone(), dir_env_val);
|
||||||
}
|
}
|
||||||
} //else {
|
} else {
|
||||||
//Otherwise, we just track that we added it here
|
//Otherwise, we just track that we added it here
|
||||||
// self.added_env_vars
|
self.added_env_vars
|
||||||
// .entry(wdir.to_path_buf())
|
.entry(wdir.to_path_buf())
|
||||||
// .or_insert(IndexSet::new())
|
.or_insert(IndexSet::new())
|
||||||
// .insert(dir_env_key.clone());
|
.insert(dir_env_key.clone());
|
||||||
// std::env::set_var(dir_env_key, dir_env_val.clone());
|
vars_to_add.insert(dir_env_key.clone(), dir_env_val);
|
||||||
// vars_to_add.insert(dir_env_key.clone(), dir_env_val);
|
seen_vars.insert(dir_env_key.clone());
|
||||||
// seen_vars.insert(dir_env_key.clone());
|
}
|
||||||
//}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,15 +131,6 @@ impl DirectorySpecificEnvironment {
|
||||||
.parent();
|
.parent();
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut file = OpenOptions::new()
|
|
||||||
.write(true)
|
|
||||||
.append(true)
|
|
||||||
.create(true)
|
|
||||||
.open("toadd.txt")
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
write!(&mut file, "adding: {:?}\n", vars_to_add).unwrap();
|
|
||||||
|
|
||||||
Ok(vars_to_add)
|
Ok(vars_to_add)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
6
crates/nu-cli/src/env/environment.rs
vendored
6
crates/nu-cli/src/env/environment.rs
vendored
|
@ -60,9 +60,9 @@ impl Environment {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn maintain_directory_environment(&mut self) -> std::io::Result<()> {
|
pub fn maintain_directory_environment(&mut self) -> std::io::Result<()> {
|
||||||
// self.direnv.env_vars_to_delete()?.iter().for_each(|k| {
|
self.direnv.env_vars_to_delete()?.iter().for_each(|k| {
|
||||||
// self.remove_env(&k);
|
self.remove_env(&k);
|
||||||
// });
|
});
|
||||||
|
|
||||||
// self.direnv
|
// self.direnv
|
||||||
// .overwritten_values_to_restore()?
|
// .overwritten_values_to_restore()?
|
||||||
|
|
Loading…
Reference in New Issue
Block a user