MiniDevil
As beautiful as a shell
Shell builtin commands prototypes. More...
#include "structs.h"
Include dependency graph for builtins.h:
This graph shows which files directly or indirectly include this file:Shell builtin commands prototypes.
Definition in file builtins.h.
Functions | |
| int | builtin_echo (char **args) |
Implement the echo command. More... | |
| int | builtin_pwd (void) |
Implement the pwd command. More... | |
| int | builtin_cd (char **args, t_env **env) |
Implement the cd command. More... | |
| int | builtin_exit (char **args, t_shell *shell) |
Implement the exit command. More... | |
| int | builtin_env (char **args, t_env *env) |
Implement the env command. More... | |
| int | builtin_export (char **args, t_env **env) |
Implement the export command. More... | |
| void | print_sorted_export (t_env *env) |
| Print all env vars sorted in alphabetical order, in declare -x format. More... | |
| void | export_assign (t_env **env, char *arg) |
| Export a variable with a value (export KEY=value) More... | |
| void | export_append (t_env **env, char *arg) |
| Export a variable with append (export KEY+=value) More... | |
| void | export_no_value (t_env **env, char *key) |
| Export a variable with no value (export KEY) More... | |
| int | builtin_unset (char **args, t_env **env) |
Implement the unset command. More... | |
| int builtin_echo | ( | char ** | args | ) |
Implement the echo command.
This command prints arguments separated by spaces and supports:
| args | NULL terminated arg array with arg[0] = "echo" |
Definition at line 52 of file builtin_echo.c.
References is_n_flag().
Referenced by exec_builtin().
Here is the call graph for this function:
Here is the caller graph for this function:| int builtin_pwd | ( | void | ) |
Implement the pwd command.
Prints the current working directory to STDOUT
Definition at line 24 of file builtin_pwd.c.
Referenced by exec_builtin().
Here is the caller graph for this function:| int builtin_cd | ( | char ** | args, |
| t_env ** | env | ||
| ) |
Implement the cd command.
Changes the working directory and supports:
| args | NULL terminated argument array with arg[0] = "cd" |
| env | Pointer to env list head |
Definition at line 101 of file builtin_cd.c.
References get_cd_path(), and update_pwd_vars().
Referenced by exec_builtin().
Here is the call graph for this function:
Here is the caller graph for this function:| int builtin_exit | ( | char ** | args, |
| t_shell * | shell | ||
| ) |
Implement the exit command.
| args | NULL terminated arg array with arg[0] = "exit" |
| shell | Shell context (running flag set to 0 in order to trigger exit) |
Definition at line 29 of file builtin_exit.c.
References t_shell::exit_status, t_shell::interactive, and t_shell::running.
Referenced by exec_builtin().
Here is the caller graph for this function:| int builtin_env | ( | char ** | args, |
| t_env * | env | ||
| ) |
Implement the env command.
Print all environment variables which have a value in "KEY=VALUE" format, one per line and rejecting extra arguments.
| args | NULL terminated arguments array with arg[0] = "env" |
| env | Environment list to print |
Definition at line 26 of file builtin_env.c.
References t_env::key, t_env::next, and t_env::value.
Referenced by exec_builtin().
Here is the caller graph for this function:| int builtin_export | ( | char ** | args, |
| t_env ** | env | ||
| ) |
Implement the export command.
| args | NULL terminated arg array with arg[0] = "export" |
| env | Pointer to env list head (modified on export) |
Definition at line 99 of file builtin_export.c.
References export_one(), and print_sorted_export().
Referenced by exec_builtin().
Here is the call graph for this function:
Here is the caller graph for this function:| void print_sorted_export | ( | t_env * | env | ) |
Print all env vars sorted in alphabetical order, in declare -x format.
Used by export with no arguments
| env | Head of the env list |
Definition at line 120 of file export_utils.c.
References count_env(), env_to_node_array(), print_one_export(), and sort_env_array().
Referenced by builtin_export().
Here is the call graph for this function:
Here is the caller graph for this function:| void export_assign | ( | t_env ** | env, |
| char * | arg | ||
| ) |
Export a variable with a value (export KEY=value)
Split the argument at = to extract key and value then call set_env_value() to create or update the variable
| env | Pointer to env list head |
| arg | Full argument string containing = somewhere |
Definition at line 55 of file export_ops.c.
References set_env_value().
Referenced by export_one().
Here is the call graph for this function:
Here is the caller graph for this function:| void export_append | ( | t_env ** | env, |
| char * | arg | ||
| ) |
Export a variable with append (export KEY+=value)
Splits at += and builds the appended value using get_append_value() then calls set_env_value() to update the variable
| env | Pointer to env list head |
| arg | Full arg string containing "+=" |
Definition at line 104 of file export_ops.c.
References get_append_value(), and set_env_value().
Referenced by export_one().
Here is the call graph for this function:
Here is the caller graph for this function:| void export_no_value | ( | t_env ** | env, |
| char * | key | ||
| ) |
Export a variable with no value (export KEY)
| env | Pointer to env list head |
| key | Variable name to export |
Definition at line 26 of file export_ops.c.
References add_env_node(), t_env::key, t_env::next, and t_env::value.
Referenced by export_one().
Here is the call graph for this function:
Here is the caller graph for this function:| int builtin_unset | ( | char ** | args, |
| t_env ** | env | ||
| ) |
Implement the unset command.
Remove named variables from environment
-) return error 2| args | NULL terminated arg array with arg[0] = "unset" |
| env | Pointer to env list head (nodes will be removed) |
Definition at line 86 of file builtin_unset.c.
References is_valid_unset_identifier(), and remove_env_node().
Referenced by exec_builtin().
Here is the call graph for this function:
Here is the caller graph for this function: