mirror of
https://github.com/TECHNOFAB11/pay-respects.git
synced 2025-12-12 14:30:10 +01:00
fix: trim newlines when expanding alias
This commit is contained in:
parent
d76a244a1a
commit
cf04753c2b
3 changed files with 9 additions and 2 deletions
|
|
@ -51,7 +51,6 @@ fn main() -> Result<(), std::io::Error> {
|
||||||
init.ok().unwrap()
|
init.ok().unwrap()
|
||||||
};
|
};
|
||||||
|
|
||||||
data.expand_command();
|
|
||||||
use shell::Mode::*;
|
use shell::Mode::*;
|
||||||
match data.mode {
|
match data.mode {
|
||||||
Suggestion => modes::suggestion(&mut data),
|
Suggestion => modes::suggestion(&mut data),
|
||||||
|
|
|
||||||
|
|
@ -163,12 +163,14 @@ impl Data {
|
||||||
};
|
};
|
||||||
|
|
||||||
init.split();
|
init.split();
|
||||||
|
init.expand_command();
|
||||||
if init.mode != Mode::Cnf {
|
if init.mode != Mode::Cnf {
|
||||||
init.update_error(None);
|
init.update_error(None);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(debug_assertions)]
|
#[cfg(debug_assertions)]
|
||||||
{
|
{
|
||||||
|
eprintln!("/// data initialization");
|
||||||
eprintln!("shell: {}", init.shell);
|
eprintln!("shell: {}", init.shell);
|
||||||
eprintln!("command: {}", init.command);
|
eprintln!("command: {}", init.command);
|
||||||
eprintln!("error: {}", init.error);
|
eprintln!("error: {}", init.error);
|
||||||
|
|
@ -209,6 +211,8 @@ impl Data {
|
||||||
self.command = self.command.replacen(&split[0], "", 1).trim().to_string();
|
self.command = self.command.replacen(&split[0], "", 1).trim().to_string();
|
||||||
self.privilege = Some(split.remove(0))
|
self.privilege = Some(split.remove(0))
|
||||||
}
|
}
|
||||||
|
#[cfg(debug_assertions)]
|
||||||
|
eprintln!("split: {:?}", split);
|
||||||
self.split = split;
|
self.split = split;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -454,7 +458,7 @@ pub fn expand_alias_multiline(map: &HashMap<String, String>, command: &str) -> O
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if expansion {
|
if expansion {
|
||||||
Some(expanded)
|
Some(expanded.trim().to_string())
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,10 @@ pub fn suggest_candidates(data: &mut Data) {
|
||||||
|
|
||||||
#[cfg(debug_assertions)]
|
#[cfg(debug_assertions)]
|
||||||
{
|
{
|
||||||
|
eprintln!("/// suggest_candidates");
|
||||||
|
eprintln!("split: {:?}", data.split);
|
||||||
|
eprintln!("command: {command}");
|
||||||
|
eprintln!("privilege: {privilege:?}");
|
||||||
eprintln!("modules: {modules:?}");
|
eprintln!("modules: {modules:?}");
|
||||||
eprintln!("fallbacks: {fallbacks:?}");
|
eprintln!("fallbacks: {fallbacks:?}");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue