Ready for testing
This commit is contained in:
parent
b6a7f56a1e
commit
542d7ac2a1
5
crates/nu-cli/src/env/TODO.org
vendored
5
crates/nu-cli/src/env/TODO.org
vendored
|
@ -20,4 +20,7 @@ returning =None=, which completely skips running the code for dealing with direc
|
|||
- This holds even if the old value was set by a .nu in a parent directory. The overwritten value is restored when you leave the directory.
|
||||
** Security
|
||||
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 nu_protocol::{Primitive, UntaggedValue, Value};
|
||||
use std::io::Write;
|
||||
use std::{
|
||||
ffi::OsString,
|
||||
fmt::Debug,
|
||||
fs::OpenOptions,
|
||||
io::{Error, ErrorKind, Result},
|
||||
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 let Some(existing_val) = std::env::var_os(dir_env_key) {
|
||||
if !seen_vars.contains(dir_env_key) {
|
||||
// self.overwritten_env_vars
|
||||
// .entry(wdir.to_path_buf())
|
||||
// .or_insert(IndexMap::new())
|
||||
// .insert(dir_env_key.clone(), existing_val);
|
||||
self.overwritten_env_vars
|
||||
.entry(wdir.to_path_buf())
|
||||
.or_insert(IndexMap::new())
|
||||
.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());
|
||||
vars_to_add.insert(dir_env_key.clone(), dir_env_val);
|
||||
}
|
||||
} //else {
|
||||
} else {
|
||||
//Otherwise, we just track that we added it here
|
||||
// self.added_env_vars
|
||||
// .entry(wdir.to_path_buf())
|
||||
// .or_insert(IndexSet::new())
|
||||
// .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);
|
||||
// seen_vars.insert(dir_env_key.clone());
|
||||
//}
|
||||
self.added_env_vars
|
||||
.entry(wdir.to_path_buf())
|
||||
.or_insert(IndexSet::new())
|
||||
.insert(dir_env_key.clone());
|
||||
vars_to_add.insert(dir_env_key.clone(), dir_env_val);
|
||||
seen_vars.insert(dir_env_key.clone());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -135,15 +131,6 @@ impl DirectorySpecificEnvironment {
|
|||
.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)
|
||||
}
|
||||
|
||||
|
|
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<()> {
|
||||
// self.direnv.env_vars_to_delete()?.iter().for_each(|k| {
|
||||
// self.remove_env(&k);
|
||||
// });
|
||||
self.direnv.env_vars_to_delete()?.iter().for_each(|k| {
|
||||
self.remove_env(&k);
|
||||
});
|
||||
|
||||
// self.direnv
|
||||
// .overwritten_values_to_restore()?
|
||||
|
|
Loading…
Reference in New Issue
Block a user