fix: trim newlines when expanding alias

This commit is contained in:
iff 2025-03-12 03:18:28 +01:00
parent d76a244a1a
commit cf04753c2b
3 changed files with 9 additions and 2 deletions

View file

@ -51,7 +51,6 @@ fn main() -> Result<(), std::io::Error> {
init.ok().unwrap()
};
data.expand_command();
use shell::Mode::*;
match data.mode {
Suggestion => modes::suggestion(&mut data),

View file

@ -163,12 +163,14 @@ impl Data {
};
init.split();
init.expand_command();
if init.mode != Mode::Cnf {
init.update_error(None);
}
#[cfg(debug_assertions)]
{
eprintln!("/// data initialization");
eprintln!("shell: {}", init.shell);
eprintln!("command: {}", init.command);
eprintln!("error: {}", init.error);
@ -209,6 +211,8 @@ impl Data {
self.command = self.command.replacen(&split[0], "", 1).trim().to_string();
self.privilege = Some(split.remove(0))
}
#[cfg(debug_assertions)]
eprintln!("split: {:?}", split);
self.split = split;
}
@ -454,7 +458,7 @@ pub fn expand_alias_multiline(map: &HashMap<String, String>, command: &str) -> O
}
}
if expansion {
Some(expanded)
Some(expanded.trim().to_string())
} else {
None
}

View file

@ -30,6 +30,10 @@ pub fn suggest_candidates(data: &mut Data) {
#[cfg(debug_assertions)]
{
eprintln!("/// suggest_candidates");
eprintln!("split: {:?}", data.split);
eprintln!("command: {command}");
eprintln!("privilege: {privilege:?}");
eprintln!("modules: {modules:?}");
eprintln!("fallbacks: {fallbacks:?}");
}