mirror of
https://github.com/nushell/nushell.git
synced 2025-05-02 00:54:25 +02:00
Fix path
This commit is contained in:
parent
15a8e26664
commit
1b83248558
@ -1,6 +1,6 @@
|
|||||||
use super::autoenv::Allowed;
|
use super::{autoenv::Allowed, cd::CdArgs};
|
||||||
use crate::commands::WholeStreamCommand;
|
use crate::commands::WholeStreamCommand;
|
||||||
use crate::prelude::*;
|
use crate::{path, prelude::*};
|
||||||
use nu_errors::ShellError;
|
use nu_errors::ShellError;
|
||||||
use nu_protocol::SyntaxShape;
|
use nu_protocol::SyntaxShape;
|
||||||
use nu_protocol::{Primitive, ReturnSuccess, Signature, UntaggedValue, Value};
|
use nu_protocol::{Primitive, ReturnSuccess, Signature, UntaggedValue, Value};
|
||||||
@ -29,16 +29,19 @@ impl WholeStreamCommand for AutoenvTrust {
|
|||||||
registry: &CommandRegistry,
|
registry: &CommandRegistry,
|
||||||
) -> Result<OutputStream, ShellError> {
|
) -> Result<OutputStream, ShellError> {
|
||||||
let tag = args.call_info.name_tag.clone();
|
let tag = args.call_info.name_tag.clone();
|
||||||
|
|
||||||
let dir_to_allow = match args.call_info.evaluate(registry).await?.args.nth(0) {
|
let dir_to_allow = match args.call_info.evaluate(registry).await?.args.nth(0) {
|
||||||
Some(Value {
|
Some(Value {
|
||||||
value: UntaggedValue::Primitive(Primitive::String(ref path)),
|
value: UntaggedValue::Primitive(Primitive::String(ref path)),
|
||||||
tag: _,
|
tag: _,
|
||||||
}) => path.clone(),
|
}) => path::absolutize(std::env::current_dir()?, path)
|
||||||
|
.to_string_lossy()
|
||||||
|
.to_string(),
|
||||||
_ => std::env::current_dir()?.to_string_lossy().to_string(),
|
_ => std::env::current_dir()?.to_string_lossy().to_string(),
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut env_file_to_allow = PathBuf::from(dir_to_allow.clone());
|
let mut env_file_to_allow = PathBuf::from(dir_to_allow.clone());
|
||||||
env_file_to_allow.push(".nu-env");
|
env_file_to_allow.push(".nu-env");
|
||||||
|
|
||||||
let content = std::fs::read_to_string(env_file_to_allow)?;
|
let content = std::fs::read_to_string(env_file_to_allow)?;
|
||||||
let mut hasher = DefaultHasher::new();
|
let mut hasher = DefaultHasher::new();
|
||||||
content.hash(&mut hasher);
|
content.hash(&mut hasher);
|
||||||
|
Loading…
Reference in New Issue
Block a user