@@ -6,7 +6,7 @@ use nu_protocol::SyntaxShape;
66use nu_protocol:: { Primitive , ReturnSuccess , Signature , UntaggedValue , Value } ;
77use std:: hash:: { Hash , Hasher } ;
88use std:: io:: Read ;
9- use std:: { collections:: hash_map:: DefaultHasher , fs, path:: PathBuf } ;
9+ use std:: { collections:: hash_map:: DefaultHasher , ffi :: OsStr , fs, path:: PathBuf } ;
1010pub struct AutoenvTrust ;
1111
1212#[ async_trait]
@@ -33,12 +33,12 @@ impl WholeStreamCommand for AutoenvTrust {
3333 Some ( Value {
3434 value : UntaggedValue :: Primitive ( Primitive :: String ( ref path) ) ,
3535 tag : _,
36- } ) => path . clone ( ) ,
37- _ => std:: env:: current_dir ( ) ?. to_string_lossy ( ) . to_string ( ) ,
36+ } ) => PathBuf :: from ( path ) ,
37+ _ => std:: env:: current_dir ( ) ?,
3838 } ;
3939
4040 let mut env_file_to_allow = dir_to_allow. clone ( ) ;
41- env_file_to_allow. push_str ( "/ .nu-env") ;
41+ env_file_to_allow. push ( " .nu-env") ;
4242 let content = std:: fs:: read_to_string ( env_file_to_allow) ?;
4343 let mut hasher = DefaultHasher :: new ( ) ;
4444 content. hash ( & mut hasher) ;
@@ -67,7 +67,7 @@ impl WholeStreamCommand for AutoenvTrust {
6767 } ) ;
6868 allowed
6969 . dirs
70- . insert ( dir_to_allow, hasher. finish ( ) . to_string ( ) ) ;
70+ . insert ( dir_to_allow. as_os_str ( ) , hasher. finish ( ) . to_string ( ) ) ;
7171
7272 fs:: write ( config_path, toml:: to_string ( & allowed) . unwrap ( ) )
7373 . expect ( "Couldn't write to toml file" ) ;
0 commit comments