Skip to main content

parse_shell_file

Function parse_shell_file 

Source
pub fn parse_shell_file(
    path: &Path,
    target_var: &str,
    current_value: Option<&str>,
) -> Result<Vec<ParsedShellEntry>>
Expand description

Parse a shell script file for variable assignments

Handles common bash/zsh patterns:

  • export VAR=value
  • VAR=value
  • export VAR (export existing variable)
  • unset VAR
  • PATH=“$PATH:new” (append)
  • PATH=“new:$PATH” (prepend)
  • [ -f x ] && export VAR=y (conditional)
  • source file / . file