Implement sourcing for shedenv and shed_profile, and also check /etc/shed for global shedrc/shed_profile/shedenv files

This commit is contained in:
2026-03-15 23:02:11 -04:00
parent 7e2763bb80
commit 067b4f6184
2 changed files with 67 additions and 8 deletions

View File

@@ -40,7 +40,7 @@ use crate::readline::term::{LineWriter, RawModeGuard, raw_mode};
use crate::readline::{Prompt, ReadlineEvent, ShedVi};
use crate::signal::{GOT_SIGWINCH, JOB_DONE, QUIT_CODE, check_signals, sig_setup, signals_pending};
use crate::state::{
AutoCmdKind, read_logic, read_shopts, source_rc, write_jobs, write_meta, write_shopts,
AutoCmdKind, read_logic, read_shopts, source_env, source_login, source_rc, write_jobs, write_meta, write_shopts
};
use clap::Parser;
use state::write_vars;
@@ -128,6 +128,10 @@ fn main() -> ExitCode {
unsafe { env::set_var("SHLVL", "1") };
}
if let Err(e) = source_env() {
e.print_error();
}
if let Err(e) = if let Some(cmd) = args.command {
exec_dash_c(cmd)
} else if args.stdin || !isatty(STDIN_FILENO).unwrap_or(false) {
@@ -217,6 +221,11 @@ fn shed_interactive(args: ShedArgs) -> ShResult<()> {
let _raw_mode = raw_mode(); // sets raw mode, restores termios on drop
sig_setup(args.login_shell);
if args.login_shell
&& let Err(e) = source_login() {
e.print_error();
}
if let Err(e) = source_rc() {
e.print_error();
}