MiniDevil
As beautiful as a shell
Environment queries: searches, gets, and sets variables. More...
Include dependency graph for env_operations.c:Environment queries: searches, gets, and sets variables.
Definition in file env_operations.c.
Functions | |
| char * | get_env_value (t_env *env_list, char *key) |
| Look up an environment variable's value by its key. More... | |
| static int | update_existing_var (t_env *env_list, char *key, char *value) |
| Update the value of an existing environment variable. More... | |
| static int | create_new_var (t_env **env_list, char *key, char *value) |
| Create a new variable and add it to the list. More... | |
| int | set_env_value (t_env **env_list, char *key, char *value) |
| Set or create an environment variable. More... | |
| char* get_env_value | ( | t_env * | env_list, |
| char * | key | ||
| ) |
Look up an environment variable's value by its key.
| env_list | List head to search |
| key | Variable name to find |
Definition at line 23 of file env_operations.c.
References t_env::key, t_env::next, and t_env::value.
Referenced by ensure_pwd(), expand_tilde(), find_cmd_path(), get_append_value(), get_cd_path(), get_home_path(), handle_shlvl(), and process_dollar().
Here is the caller graph for this function:
|
static |
Update the value of an existing environment variable.
| env_list | List head to search |
| key | Variable name to match |
| value | New value to set |
Definition at line 50 of file env_operations.c.
References t_env::key, t_env::next, and t_env::value.
Referenced by set_env_value().
Here is the caller graph for this function:
|
static |
Create a new variable and add it to the list.
Creates a node via create_env_node() and adds it to the list (the temporary string is freed after use)
| env_list | Pointer to list head pointer |
| key | Variable name |
| value | Variable value |
Definition at line 83 of file env_operations.c.
References add_env_node(), and create_env_node().
Referenced by set_env_value().
Here is the call graph for this function:
Here is the caller graph for this function:| int set_env_value | ( | t_env ** | env_list, |
| char * | key, | ||
| char * | value | ||
| ) |
Set or create an environment variable.
It first tries to update and existing variable, and if the key is not found, it creates a new node and adds it to the list
| env_list | Pointer to list head pointer |
| key | Variable name |
| value | New value |
Definition at line 115 of file env_operations.c.
References create_new_var(), and update_existing_var().
Referenced by ensure_pwd(), export_append(), export_assign(), handle_shlvl(), and update_pwd_vars().
Here is the call graph for this function:
Here is the caller graph for this function: