Load stdlib with shell state ahead of configuration

This commit is contained in:
Ava Apples Affine 2023-06-06 11:31:31 -07:00
parent 981df23ea2
commit a9cc38826e

View file

@ -246,9 +246,23 @@ fn main() {
load_defaults(&mut syms);
load_environment(&mut syms);
static_stdlib(&mut syms);
// reload this later with the state bindings
#[cfg(feature="posix")]
dynamic_stdlib(&mut syms, None);
let prompt_ss: Rc<RefCell<ShellState>>;
#[cfg(feature="posix")]
{
let shell_state_bindings = Rc::new(RefCell::from(ShellState {
parent_pid: unistd::Pid::from_raw(0),
parent_sid: unistd::Pid::from_raw(0),
children: vec![],
last_exit_code: 0,
attr: None,
}));
prompt_ss = shell_state_bindings.clone();
dynamic_stdlib(&mut syms, Some(shell_state_bindings));
}
// reload this later with the state bindings
#[cfg(not(feature="posix"))]
dynamic_stdlib(&mut syms);
@ -271,19 +285,9 @@ fn main() {
.unwrap_or_else(|err: Traceback| eprintln!("failed to load script {}\n{}", cfg_file, err));
}
#[cfg(feature="posix")]
let prompt_ss: Rc<RefCell<ShellState>>;
#[cfg(feature="posix")]
{
let shell_state_bindings = Rc::new(RefCell::from(ShellState {
parent_pid: unistd::Pid::from_raw(0),
parent_sid: unistd::Pid::from_raw(0),
children: vec![],
last_exit_code: 0,
attr: None,
}));
prompt_ss = shell_state_bindings.clone();
dynamic_stdlib(&mut syms, Some(shell_state_bindings));
dynamic_stdlib(&mut syms, Some(prompt_ss.clone()));
}
// setup readline