fully interactive shell

* Background task implementation
* Foreground an existing task implementation
* Documentation for both
* Refactors to signal handling, process pre-exec
This commit is contained in:
Ava Apples Affine 2023-05-18 06:53:23 +00:00
parent 69216db72a
commit c127118465
8 changed files with 535 additions and 107 deletions

View file

@ -25,7 +25,7 @@ use {
stdlib::{
static_stdlib, dynamic_stdlib
},
aux::ShellState,
aux::{ShellState, check_jobs},
},
std::{
cell::RefCell,
@ -169,7 +169,6 @@ impl Completer for CustomCompleter {
if e.file_name()
.to_string_lossy()
.starts_with(path.file_name()
// TODO: dont
.expect("bad file somehow?")
.to_string_lossy()
.to_mut()
@ -220,12 +219,16 @@ fn main() {
let hist_file_name = home_dir.clone() + HIST_FILE;
let cfg_file_name = home_dir + CONFIG_FILE_DEFAULT;
// TODO: the next two decls should probably be conditional on CFG_RELISH_POSIX
// but in both cases the data must live for the whole program
let shell_state_bindings = Rc::new(RefCell::from(ShellState {
parent_pid: unistd::Pid::from_raw(0),
parent_pgid: unistd::Pid::from_raw(0),
parent_sid: unistd::Pid::from_raw(0),
children: vec![],
last_exit_code: 0,
attr: None,
}));
let prompt_ss = shell_state_bindings.clone();
// setup symtable
let mut syms = SymTable::new();
@ -281,8 +284,10 @@ fn main() {
.with_style(Style::new().italic().fg(Color::LightGray)),
)).with_validator(Box::new(DefaultValidator));
// repl :)
loop {
{
check_jobs(&mut prompt_ss.borrow_mut());
}
let readline_prompt = make_prompt(&mut syms);
let completer = make_completer(&mut syms);
// realloc with each loop because syms can change