Added an on-exit hook for autocmd

improved mode-switching autocmd hook logic

fixed escaping logic in single quote expansion
This commit is contained in:
2026-03-04 14:29:44 -05:00
parent fbadbebf8c
commit 12267716be
5 changed files with 30 additions and 7 deletions

View File

@@ -118,14 +118,17 @@ fn main() -> ExitCode {
} else {
shed_interactive(args)
} {
eprintln!("shed: {e}");
e.print_error();
};
if let Some(trap) = read_logic(|l| l.get_trap(TrapTarget::Exit))
&& let Err(e) = exec_input(trap, None, false, Some("trap".into())) {
eprintln!("shed: error running EXIT trap: {e}");
e.print_error();
}
let on_exit_autocmds = read_logic(|l| l.get_autocmds(AutoCmdKind::OnExit));
on_exit_autocmds.exec();
write_jobs(|j| j.hang_up());
ExitCode::from(QUIT_CODE.load(Ordering::SeqCst) as u8)
}