From 6800e5c2b9ead3c87a6508e2d26905239d8cea16 Mon Sep 17 00:00:00 2001 From: Ava Affine Date: Tue, 20 Feb 2024 14:51:05 -0800 Subject: [PATCH] quick fix, simplify cd callback behaviour Signed-off-by: Ava Affine --- src/stl/posix.rs | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/src/stl/posix.rs b/src/stl/posix.rs index 6fd6f6a..8c76d66 100644 --- a/src/stl/posix.rs +++ b/src/stl/posix.rs @@ -762,6 +762,10 @@ fn cd_callback(ast: &Seg, syms: &mut SymTable) -> Result { 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 ..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 { - Ok(Ctr::None) - })), - ..Default::default() - }, - ); }