diff --git a/crates/nu-cli/src/commands/autoenv_trust.rs b/crates/nu-cli/src/commands/autoenv_trust.rs index 3b13e13e92..4e0f81c28e 100644 --- a/crates/nu-cli/src/commands/autoenv_trust.rs +++ b/crates/nu-cli/src/commands/autoenv_trust.rs @@ -50,10 +50,9 @@ impl WholeStreamCommand for AutoenvTrust { let filename = file_to_trust.to_string_lossy().to_string(); let mut allowed = Trusted::read_trusted()?; - allowed.files.insert( - filename, - Sha256::digest(&content).as_slice().to_vec() - ); + allowed + .files + .insert(filename, Sha256::digest(&content).as_slice().to_vec()); let config_path = config::default_path_for(&Some(PathBuf::from("nu-env.toml")))?; let tomlstr = toml::to_string(&allowed).or_else(|_| { diff --git a/crates/nu-cli/src/env/directory_specific_environment.rs b/crates/nu-cli/src/env/directory_specific_environment.rs index 313ebd0bc2..3adbd947c0 100644 --- a/crates/nu-cli/src/env/directory_specific_environment.rs +++ b/crates/nu-cli/src/env/directory_specific_environment.rs @@ -38,11 +38,10 @@ impl DirectorySpecificEnvironment { if trusted.files.get(wdirenv.to_str().unwrap_or("")) == Some(&Sha256::digest(&content).as_slice().to_vec()) { - let content = std::str::from_utf8(&content.as_slice()).or_else(|_| { + return Ok(std::str::from_utf8(&content.as_slice()).or_else(|_| { Err(ShellError::untagged_runtime_error(format!("Could not read {:?} as utf8 string", content))) - })?; - let content = std::fs::read_to_string(&wdirenv)?; - return Ok(content.parse::().or_else(|_| { + })? + .parse::().or_else(|_| { Err(ShellError::untagged_runtime_error(format!( "Could not parse {:?}. Is it well-formed? Each entry must be written as key = \"value\" (note the quotation marks)", wdirenv