MiniDevil
As beautiful as a shell
Command path resolution: searches PATH & validates permissions. More...
Include dependency graph for path.c:Command path resolution: searches PATH & validates permissions.
Definition in file path.c.
Functions | |
| static int | is_direct_path (char *cmd) |
| Check if a command contains a slash (= direct path) More... | |
| static char * | join_path (char *dir, char *cmd) |
Join a directory and command name with a / in between. More... | |
| char * | search_in_dir (char *dir, char *cmd) |
| Search an executable command in a directory. More... | |
| static char * | search_in_path (char *cmd, char *path_var) |
| Search for a command in all PATH directories. More... | |
| char * | find_cmd_path (char *cmd, t_env *env) |
| Resolve a command name into its full executable path. More... | |
|
static |
Check if a command contains a slash (= direct path)
| cmd | Command to check |
/ and 0 if not Definition at line 23 of file path.c.
Referenced by find_cmd_path().
Here is the caller graph for this function:
|
static |
Join a directory and command name with a / in between.
| dir | Directory path |
| cmd | Command name |
Definition at line 39 of file path.c.
Referenced by search_in_dir().
Here is the caller graph for this function:| char* search_in_dir | ( | char * | dir, |
| char * | cmd | ||
| ) |
Search an executable command in a directory.
Joins dir and cmd then checks if their result is executable via access(X_OK)
| dir | Directory to search in |
| cmd | Command name to look for |
Definition at line 61 of file path.c.
References join_path().
Referenced by find_cmd_path(), and search_in_path().
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Search for a command in all PATH directories.
Splits the PATH variable (by :) and tries each directory
| cmd | Command name to search for |
| path_var | Value of the PATH environment variable |
Definition at line 85 of file path.c.
References search_in_dir().
Referenced by find_cmd_path().
Here is the call graph for this function:
Here is the caller graph for this function:| char* find_cmd_path | ( | char * | cmd, |
| t_env * | env | ||
| ) |
Resolve a command name into its full executable path.
If the command contains / it's treated as a direct path. Otherwise it looks up PATH in env and searches each directory until an executable match is found
| cmd | Command name or path to resolve |
| env | Environment list |
Definition at line 115 of file path.c.
References get_env_value(), is_direct_path(), search_in_dir(), and search_in_path().
Referenced by prepare_exec().
Here is the call graph for this function:
Here is the caller graph for this function: