fixed new crash caused by recent refactor

This commit is contained in:
2026-02-24 14:18:15 -05:00
parent 238a0063f8
commit 478374814e
2 changed files with 7 additions and 8 deletions

View File

@@ -681,7 +681,7 @@ impl Dispatcher {
}
fn exec_builtin(&mut self, cmd: Node) -> ShResult<()> {
let fork_builtins = cmd.flags.contains(NdFlags::FORK_BUILTINS);
let cmd_raw = cmd.get_command().unwrap().to_string();
let cmd_raw = cmd.get_command().unwrap_or_else(|| panic!("expected command NdRule, got {:?}", &cmd.class)).to_string();
if fork_builtins {
log::trace!("Forking builtin: {}", cmd_raw);

View File

@@ -114,15 +114,14 @@ pub struct Node {
impl Node {
pub fn get_command(&self) -> Option<&Tk> {
let NdRule::Command {
if let NdRule::Command {
assignments: _,
argv,
} = &self.class
else {
return None;
};
let command = argv.iter().find(|tk| tk.flags.contains(TkFlags::IS_CMD))?;
Some(command)
} = &self.class {
argv.iter().next()
} else {
None
}
}
pub fn get_span(&self) -> Span {
let Some(first_tk) = self.tokens.first() else {