Skip to content

Commit aae4f2d

Browse files
fix sudo ...
1 parent 687a4ca commit aae4f2d

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

command/src/commands/arg.rs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,20 @@ pub fn command_match(commands: Commands,session_context: &mut SessionContext) ->
7070
#[allow(unused_assignments)]
7171
pub fn execute_command(command: &str, option: &str, arg: &Vec<String>, session_context: &mut SessionContext) -> Result<(usize,String), std::io::Error> {
7272
match command {
73-
"sudo" => {
74-
let output = sudo(session_context);
75-
output
73+
"sudo" => match arg.is_empty(){
74+
true => {
75+
let output = sudo(session_context);
76+
output
77+
},
78+
false => {
79+
let output = sudo(session_context).ok();
80+
assert_eq!(output.unwrap().0,0);
81+
82+
let command = turn_command(arg.to_vec());
83+
let res = command_match(command, session_context);
84+
session_context.user_state.exit_root();
85+
res
86+
}
7687
},
7788
"exit" => {
7889
match option{

command/src/commands/command.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,7 @@ pub fn echo_print<T: std::fmt::Display + From<String>>(output: T) -> (usize,T){
571571
}
572572

573573
// turn vec<_> to Commands
574-
fn turn_command(v: Vec<String>) -> Commands{
574+
pub fn turn_command(v: Vec<String>) -> Commands{
575575
let ouput = Commands::new(v);
576576
ouput
577577
}

0 commit comments

Comments
 (0)