MiniDevil
As beautiful as a shell
Variable expansion: replaces $VARIABLES and $? More...
Include dependency graph for expander.c:Variable expansion: replaces $VARIABLES and $?
Definition in file expander.c.
Functions | |
| static int | handle_special_var (char *str, char **result, int exit_status) |
| Handle $? expansion (last exit status) More... | |
| static int | process_dollar (char *str, int i, char **result, t_env *env_list) |
| Process a normal $VARIABLE expansion. More... | |
| static int | handle_dollar_sign (char *str, char **result, t_env *env_list, int exit_status) |
| Dispatch $ expansion (special vars then normal) More... | |
| char * | expand_variables (char *str, t_env *env_list, t_quote_type quote_type, int exit_status) |
| Expand all $VARIABLE in a string. More... | |
| int | expand_all_tokens (t_token *tokens, t_shell *shell) |
| Expand all token values before parsing. More... | |
|
static |
Handle $? expansion (last exit status)
| str | Input at $ |
| result | Pointer to the result string being built |
| exit_status | The last exit status |
Definition at line 25 of file expander.c.
References append_str().
Referenced by handle_dollar_sign().
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Process a normal $VARIABLE expansion.
Extracts the variable name after $ and looks it up in the env list, then appends its value to result. A single $ appends a literal $
| str | Input string |
| i | Position of the $ character in str |
| result | Pointer to the result string being built |
| env_list | Environment list |
$ var_name_len + 1 for $VAR) Definition at line 51 of file expander.c.
References append_char(), append_str(), extract_var_name(), and get_env_value().
Referenced by handle_dollar_sign().
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Dispatch $ expansion (special vars then normal)
| str | Input at the $ char |
| result | Pointer to the result string being built |
| env_list | Environment list |
| exit_status | Exit status for $? |
Definition at line 88 of file expander.c.
References append_char(), handle_special_var(), is_var_char(), and process_dollar().
Referenced by expand_variables().
Here is the call graph for this function:
Here is the caller graph for this function:| char* expand_variables | ( | char * | str, |
| t_env * | env_list, | ||
| t_quote_type | quote_type, | ||
| int | exit_status | ||
| ) |
Expand all $VARIABLE in a string.
| str | Input string |
| env_list | Environment list for the variables lookups |
| quote_type | Quote context (QUOTE_SINGLE = no expansion) |
| exit_status | Last exit status for $? expansion |
Definition at line 111 of file expander.c.
References append_char(), handle_dollar_sign(), and QUOTE_SINGLE.
Referenced by expand_full(), and write_heredoc_line().
Here is the call graph for this function:
Here is the caller graph for this function:Expand all token values before parsing.
<<) are not exp$ connected to a quoted token is replaced with an empty string| tokens | Token list head |
| shell | Shell state |
Definition at line 150 of file expander.c.
References t_shell::env, t_shell::exit_status, expand_full(), is_dollar_quote(), t_token::next, QUOTE_SINGLE, t_token::quote_type, TOKEN_HEREDOC, TOKEN_WORD, t_token::type, and t_token::value.
Referenced by process_input(), and process_ui_input().
Here is the call graph for this function:
Here is the caller graph for this function: