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() - }, - ); }