mirror of
https://github.com/TECHNOFAB11/pay-respects.git
synced 2025-12-12 14:30:10 +01:00
fix: edge case with only sudo command
This commit is contained in:
parent
c99c736ad5
commit
94d011cdd1
2 changed files with 9 additions and 3 deletions
|
|
@ -76,7 +76,7 @@ pub fn expand_alias(shell: &str, full_command: &str) -> String {
|
||||||
}
|
}
|
||||||
|
|
||||||
let split_command = full_command.split_whitespace().collect::<Vec<&str>>();
|
let split_command = full_command.split_whitespace().collect::<Vec<&str>>();
|
||||||
let (command, pure_command) = if PRIVILEGE_LIST.contains(&split_command[0]) {
|
let (command, pure_command) = if PRIVILEGE_LIST.contains(&split_command[0]) && split_command.len() > 1 {
|
||||||
(split_command[1], Some(split_command[1..].join(" ")))
|
(split_command[1], Some(split_command[1..].join(" ")))
|
||||||
} else {
|
} else {
|
||||||
(split_command[0], None)
|
(split_command[0], None)
|
||||||
|
|
|
||||||
|
|
@ -273,8 +273,14 @@ pub fn confirm_suggestion(shell: &str, command: &str, highlighted: &str) -> Resu
|
||||||
if !command.starts_with(&_p) {
|
if !command.starts_with(&_p) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let command = {
|
||||||
let mut command = command.replacen(&_p, "", 1);
|
let mut command = command.replacen(&_p, "", 1);
|
||||||
|
if command != " " {
|
||||||
command = expand_alias_multiline(shell, &command);
|
command = expand_alias_multiline(shell, &command);
|
||||||
|
}
|
||||||
|
command
|
||||||
|
};
|
||||||
|
|
||||||
let now = Instant::now();
|
let now = Instant::now();
|
||||||
let process = run_suggestion_p(shell, p, &command);
|
let process = run_suggestion_p(shell, p, &command);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue