Quash Shell
0.1
A simple yet powerfull shell program
|
Implements interface functions between Quash and the environment and functions that interpret an execute commands. More...
Macros | |
#define | IMPLEMENT_ME() fprintf(stderr, "IMPLEMENT ME: %s(line %d): %s()\n", __FILE__, __LINE__, __FUNCTION__) |
Note calls to any function that requires implementation. | |
Functions | |
char * | get_current_directory (bool *should_free) |
Get the real current working directory. More... | |
const char * | lookup_env (const char *env_var) |
Function to get environment variable values. 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 | child_run_command (Command cmd) |
A dispatch function to resolve the correct Command variant function for child processes. More... | |
void | parent_run_command (Command cmd) |
A dispatch function to resolve the correct Command variant function for the quash process. More... | |
void | create_process (CommandHolder holder) |
Creates one new process centered around the Command in the CommandHolder setting up redirects and pipes where needed. More... | |
void | run_script (CommandHolder *holders) |
Common entry point for all commands. More... | |
Implements interface functions between Quash and the environment and functions that interpret an execute commands.
void child_run_command | ( | Command | cmd | ) |
void create_process | ( | CommandHolder | holder | ) |
Creates one new process centered around the Command in the CommandHolder setting up redirects and pipes where needed.
holder | The CommandHolder to try to run |
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 parent_run_command | ( | Command | cmd | ) |
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 |