pub struct ShellEnv {
pub variables: HashMap<String, ShellVar>,
pub functions: HashMap<String, FunctionDef>,
pub aliases: HashMap<String, String>,
pub exit_status: i32,
pub pid: u32,
pub ppid: u32,
pub positional_params: Vec<String>,
}Expand description
The full shell environment state.
Fields§
§variables: HashMap<String, ShellVar>Named variables.
functions: HashMap<String, FunctionDef>Shell functions (stored as AST nodes).
aliases: HashMap<String, String>Aliases: name -> replacement text.
exit_status: i32Exit status of the last command ($?).
pid: u32PID of the shell process ($$).
ppid: u32Parent PID ($PPID).
positional_params: Vec<String>Positional parameters ($1, $2, …).
Implementations§
Source§impl ShellEnv
impl ShellEnv
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new environment, inheriting the OS environment variables and capturing the current PID/PPID.
Sourcepub fn set_var(&mut self, name: &str, value: &str)
pub fn set_var(&mut self, name: &str, value: &str)
Set a variable. Fails silently if the variable is read-only.
Sourcepub fn export_var(&mut self, name: &str)
pub fn export_var(&mut self, name: &str)
Mark a variable as exported.
Sourcepub fn to_env_vec(&self) -> Vec<CString>
pub fn to_env_vec(&self) -> Vec<CString>
Build the envp array for execve(2).
Returns a list of CStrings in KEY=VALUE format for every
exported variable.
Trait Implementations§
Source§impl ShellEnvironment for ShellEnv
Implements the frost_builtins::ShellEnvironment trait so that
built-in commands can interact with the shell state.
impl ShellEnvironment for ShellEnv
Implements the frost_builtins::ShellEnvironment trait so that
built-in commands can interact with the shell state.
fn get_var(&self, name: &str) -> Option<&str>
fn set_var(&mut self, name: &str, value: &str)
fn export_var(&mut self, name: &str)
fn unset_var(&mut self, name: &str)
fn exit_status(&self) -> i32
fn set_exit_status(&mut self, status: i32)
fn chdir(&mut self, path: &str) -> Result<(), String>
fn home_dir(&self) -> Option<&str>
Auto Trait Implementations§
impl Freeze for ShellEnv
impl RefUnwindSafe for ShellEnv
impl Send for ShellEnv
impl Sync for ShellEnv
impl Unpin for ShellEnv
impl UnsafeUnpin for ShellEnv
impl UnwindSafe for ShellEnv
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more