@@ -23,7 +23,7 @@ pub fn whoami(session_context: &mut SessionContext) -> io::Result<(usize,String)
23
23
pub fn help ( ) -> String {
24
24
let help = format ! (
25
25
"Usage: <command> [options] [arg]
26
- \0 \x1B [32mCommands :
26
+ \0 \x1B [32m Commands :
27
27
pwd View current directory apt -i .. Install package
28
28
ls View all files in the current directory history View past Commands
29
29
cd Change directory whoami || apt -update version
@@ -313,7 +313,7 @@ use crate::commands::download::{download_package, find_package};
313
313
use crate :: priority:: get_priority;
314
314
use crate :: set:: set:: file_create_time;
315
315
use crate :: run:: run;
316
- use crate :: state_code:: { empty_dir, empty_file, missing_pattern, STATUE_CODE } ;
316
+ use crate :: state_code:: { empty_dir, empty_file, env , missing_pattern, STATUE_CODE } ;
317
317
use super :: download:: update;
318
318
use crate :: root:: SessionContext ;
319
319
@@ -571,6 +571,30 @@ fn get_env(id: String) -> String{
571
571
}
572
572
}
573
573
574
+ use std:: path:: PathBuf ;
575
+ fn set_env_command ( key : & str , path : & str ) -> io:: Result < ( ) > {
576
+ let mut path_set = Vec :: new ( ) ;
577
+ let s = PathBuf :: from ( format ! ( "{}" , path) ) ;
578
+
579
+ path_set. push ( s) ;
580
+
581
+ let new_path = env:: join_paths ( path_set) . expect ( "Failed join paths" ) ;
582
+
583
+ env:: set_var ( key, new_path) ;
584
+ Ok ( ( ) )
585
+ }
586
+
587
+ pub fn set ( key : & str , path : & str ) -> io:: Result < ( usize , String ) > {
588
+ match set_env_command ( key, path) {
589
+ Ok ( ( ) ) =>{
590
+ return Ok ( env ( ) ) ;
591
+ } ,
592
+ Err ( _) =>{
593
+ let error_str = format ! ( "Can't set env {}" , key) ;
594
+ return Ok ( ( 108 , error_str) ) ;
595
+ }
596
+ }
597
+ }
574
598
575
599
pub fn echo_print < T : std:: fmt:: Display + From < String > > ( output : T ) -> ( usize , T ) {
576
600
let var = format ! ( "{}" , output) ;
0 commit comments