An Average Shell
- Executes commands.
- Has the ability to change the working directory with
cd
. - Shows the current working directory in the prompt.
- Shows the exit status of the last command in the prompt if it is not 0.
- Supports color terminals.
- Passes on the SIGINT signal to the foreground child.
- Supports multiple commands on one line separated with
;
. - Allows redirecting stdout and stderr using
>
,2>
,&>
, and their appending counterparts. - Allows redirecting stdin using
<
.
Passes SIGINT on to foreground child process, if one is currently running.
Prints a prompt to stdout.
Forks, with the child executing a command and the parent waiting for it.
Returns 1 if the command executed is a builtin function, 0 otherwise.
The core of the shell.
Converts a string delimited by specific characters to a character array.
Converts a given string separated by spaces into an array of strings.
Converts a given string separated by semicolons into an array of strings.
Returns dynamically allocated input read from stdin.
A partial implementation of the cd
utility, as specified by POSIX.
A partial implementation of the exit
utility, as specified by POSIX.
A default handler for errno that prints error messages to stderr.
Given the string to work with and a redirection token to look for, it "cuts" the filename out, returning that and a flag representing if we are appending to a file.
Processes redirection for stdin, returning the new file descriptor.
Processes redirection for stdout, returning the new file descriptor.
Processes redirection for stderr, returning the new file descriptor.
Handles redirection by calling the proper helper function(s).
Resets redirection to the default behavior (i.e., the state of streams before redirections were processed).
-
Does not interpret "quoted strings" as a single token.
-
Not all *alloc'd memory is freed before exiting in
builtin_exit()
. This is negligible. -
Exits with status 0 if EOF is read, regardless of the exit status of the last command.