MiniDevil
As beautiful as a shell
Implements cd: changes directory and updates OLDPWD/PWD.
More...
Include dependency graph for builtin_cd.c:Implements cd: changes directory and updates OLDPWD/PWD.
Definition in file builtin_cd.c.
Functions | |
| static char * | get_home_path (t_env *env) |
| Get the HOME value from environment. More... | |
| static char * | get_cd_path (char **args, t_env *env, int *err) |
| Get the target path for cd. More... | |
| static void | update_pwd_vars (t_env **env, char *old_pwd) |
| Update OLDPWD and PWD environment variables after cd. More... | |
| int | builtin_cd (char **args, t_env **env) |
Implement the cd command. More... | |
|
static |
Get the HOME value from environment.
| env | Environment list |
Definition at line 24 of file builtin_cd.c.
References get_env_value().
Referenced by get_cd_path().
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Get the target path for cd.
Handles no argument or "--" (HOME), "-" (OLDPWD and printed), "-- path" (path) and too many arguments (sets err = 1)
| args | Arguments array |
| env | Environment list for HOME and OLDPWD lookup |
| err | Set to 1 if too many arguments and 0 otherwise |
Definition at line 45 of file builtin_cd.c.
References get_env_value(), and get_home_path().
Referenced by builtin_cd().
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Update OLDPWD and PWD environment variables after cd.
| env | Pointer to env list head |
| old_pwd | Previous working directory (OLDPWD) |
Definition at line 78 of file builtin_cd.c.
References set_env_value().
Referenced by builtin_cd().
Here is the call graph for this function:
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: