quick fix, simplify cd callback behaviour

Signed-off-by: Ava Affine <ava@sunnypup.io>
This commit is contained in:
Ava Apples Affine 2024-02-20 14:51:05 -08:00
parent 13135def5a
commit 6800e5c2b9

View file

@ -762,6 +762,10 @@ fn cd_callback(ast: &Seg, syms: &mut SymTable) -> Result<Ctr, Traceback> {
None,
));
if !syms.contains_key(&CD_USER_CB.to_string()) {
return Ok(Ctr::None)
}
match syms.call_symbol(
&CD_USER_CB.to_string(),
&Seg::new(),
@ -990,18 +994,4 @@ pub fn load_posix_shell(syms: &mut SymTable, shell_state: Rc<RefCell<ShellState>
..Default::default()
},
);
syms.insert(
String::from(CD_USER_CB),
Symbol {
name: String::from(CD_USER_CB),
args: Args::None,
conditional_branches: false,
docs: String::from("lambda called at each invocation of cd"),
value: ValueType::Internal(Rc::new(move |_ast: &Seg, _sym: &mut SymTable| -> Result<Ctr, Traceback> {
Ok(Ctr::None)
})),
..Default::default()
},
);
}