Quash Shell
0.1
A simple yet powerfull shell program
|
Functions for interpreting and running commands. More...
Go to the source code of this file.
Functions | |
const char * | lookup_env (const char *env_var) |
Function to get environment variable values. More... | |
void | write_env (const char *env_var, const char *val) |
Function to set and define environment variable values. More... | |
char * | get_current_directory (bool *should_free) |
Get the real current working directory. More... | |
void | check_jobs_bg_status () |
Check on background jobs to see if they have exited. | |
void | print_job (int job_id, pid_t pid, const char *cmd) |
Print a job to standard out. More... | |
void | print_job_bg_start (int job_id, pid_t pid, const char *cmd) |
Print the start up of a background job to standard out. More... | |
void | print_job_bg_complete (int job_id, pid_t pid, const char *cmd) |
Print the completion of a background job to standard out. More... | |
void | run_generic (GenericCommand cmd) |
Run a generic (non-builtin) command. More... | |
void | run_echo (EchoCommand cmd) |
Run the builtin echo command. More... | |
void | run_export (ExportCommand cmd) |
Run the builtin export command. More... | |
void | run_cd (CDCommand cmd) |
Run the builtin cd (change directory) command. More... | |
void | run_kill (KillCommand cmd) |
Run the builtin kill command. More... | |
void | run_pwd () |
Run the builtin pwd (print working directory) command. More... | |
void | run_jobs () |
Run the builtin jobs command to show the jobs list. More... | |
void | run_script (CommandHolder *holders) |
Common entry point for all commands. More... | |
Functions for interpreting and running commands.
char* get_current_directory | ( | bool * | should_free | ) |
Get the real current working directory.
This is not necessarily the same as the PWD environment variable and setting PWD does not actually change the current working directory.
[out] | should_free | Set this to true if the returned string should be free'd by the caller and false otherwise. |
const char* lookup_env | ( | const char * | env_var | ) |
Function to get environment variable values.
env_var | Environment variable to lookup |
void print_job | ( | int | job_id, |
pid_t | pid, | ||
const char * | cmd | ||
) |
Print a job to standard out.
We use the minimum of what a Job structure should contain to pass to this function.
job_id | Job identifier number. |
pid | Process id of a process belonging to this job. |
cmd | String holding an approximation of what the user typed in for the command. |
void print_job_bg_complete | ( | int | job_id, |
pid_t | pid, | ||
const char * | cmd | ||
) |
Print the completion of a background job to standard out.
We use the minimum of what a Job should contain to pass to this function.
job_id | Job identifier number. |
pid | Process id of a process belonging to this job. |
cmd | String holding an aproximation of what the user typed in for the command. |
void print_job_bg_start | ( | int | job_id, |
pid_t | pid, | ||
const char * | cmd | ||
) |
Print the start up of a background job to standard out.
We use the minimum of what a Job should contain to pass to this function.
job_id | Job identifier number. |
pid | Process id of a process belonging to this job. |
cmd | String holding an aproximation of what the user typed in for the command. |
void run_cd | ( | CDCommand | cmd | ) |
void run_echo | ( | EchoCommand | cmd | ) |
void run_export | ( | ExportCommand | cmd | ) |
void run_generic | ( | GenericCommand | cmd | ) |
void run_jobs | ( | ) |
Run the builtin jobs command to show the jobs list.
void run_kill | ( | KillCommand | cmd | ) |
void run_pwd | ( | ) |
Run the builtin pwd (print working directory) command.
void run_script | ( | CommandHolder * | holders | ) |
Common entry point for all commands.
This function resolves the type of the command and calls the relevant run function
holders | An array of command holders |
void write_env | ( | const char * | env_var, |
const char * | val | ||
) |
Function to set and define environment variable values.
env_var | Environment variable to set |
val | String with the value to set the environment variable env_var |