mirror of
https://github.com/nushell/nushell.git
synced 2024-11-27 10:53:57 +01:00
Working?
This commit is contained in:
parent
c618538cf8
commit
4fdc3646e8
@ -1,7 +1,6 @@
|
|||||||
use indexmap::IndexMap;
|
use indexmap::IndexMap;
|
||||||
use nu_protocol::{Primitive, UntaggedValue, Value};
|
use nu_protocol::{Primitive, UntaggedValue, Value};
|
||||||
use std::io::Write;
|
use std::{ffi::OsString, fmt::Debug, path::PathBuf};
|
||||||
use std::{ffi::OsString, fmt::Debug, fs::OpenOptions, path::PathBuf};
|
|
||||||
|
|
||||||
#[derive(Debug, Default)]
|
#[derive(Debug, Default)]
|
||||||
pub struct DirectorySpecificEnvironment {
|
pub struct DirectorySpecificEnvironment {
|
||||||
|
11
crates/nu-cli/src/env/environment.rs
vendored
11
crates/nu-cli/src/env/environment.rs
vendored
@ -71,17 +71,6 @@ impl Environment {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn remove_env(&mut self, key: &str) {
|
|
||||||
if let Some(Value {
|
|
||||||
value: UntaggedValue::Row(ref mut envs),
|
|
||||||
tag: _,
|
|
||||||
}) = self.environment_vars
|
|
||||||
{
|
|
||||||
envs.entries.remove(key);
|
|
||||||
std::env::remove_var(key);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn morph<T: Conf>(&mut self, configuration: &T) {
|
pub fn morph<T: Conf>(&mut self, configuration: &T) {
|
||||||
self.environment_vars = configuration.env();
|
self.environment_vars = configuration.env();
|
||||||
self.path_vars = configuration.path();
|
self.path_vars = configuration.path();
|
||||||
|
23
crates/nu-cli/src/env/environment_syncer.rs
vendored
23
crates/nu-cli/src/env/environment_syncer.rs
vendored
@ -44,11 +44,6 @@ impl EnvironmentSyncer {
|
|||||||
pub fn sync_env_vars(&mut self, ctx: &mut Context) {
|
pub fn sync_env_vars(&mut self, ctx: &mut Context) {
|
||||||
let mut environment = self.env.lock();
|
let mut environment = self.env.lock();
|
||||||
|
|
||||||
// match environment.maintain_directory_environment() {
|
|
||||||
// Ok(_) => {}
|
|
||||||
// Err(e) => {panic!(e)}
|
|
||||||
// }
|
|
||||||
|
|
||||||
if environment.env().is_some() {
|
if environment.env().is_some() {
|
||||||
for (name, value) in ctx.with_host(|host| host.vars()) {
|
for (name, value) in ctx.with_host(|host| host.vars()) {
|
||||||
if name != "path" && name != "PATH" {
|
if name != "path" && name != "PATH" {
|
||||||
@ -57,22 +52,8 @@ impl EnvironmentSyncer {
|
|||||||
environment.add_env(&name, &value, false);
|
environment.add_env(&name, &value, false);
|
||||||
|
|
||||||
environment
|
environment
|
||||||
.direnv
|
.maintain_directory_environment()
|
||||||
.env_vars_to_add()
|
.expect("Could not set directory-based environment variables");
|
||||||
.unwrap()
|
|
||||||
.iter()
|
|
||||||
.for_each(|(k, v)| {
|
|
||||||
environment.add_env(&k, &v, true);
|
|
||||||
});
|
|
||||||
|
|
||||||
environment
|
|
||||||
.direnv
|
|
||||||
.overwritten_values_to_restore()
|
|
||||||
.unwrap()
|
|
||||||
.iter()
|
|
||||||
.for_each(|(k, v)| {
|
|
||||||
environment.add_env(&k, &v, true);
|
|
||||||
});
|
|
||||||
|
|
||||||
// clear the env var from the session
|
// clear the env var from the session
|
||||||
// we are about to replace them
|
// we are about to replace them
|
||||||
|
Loading…
Reference in New Issue
Block a user