pksh is a basic shell that executes commands. It is written in C and uses C library as well as POSIX functions. It supports job control, piping, and redirection. It also supports running commands from history. Signal handling for Ctrl + C and Ctrl + Z is also present.
Run make
in the directory containing the shell files.
Run ./shell
in the directory where make was just run
Run make clean
in the directory. This will remove the object files and the shell
executable for the directory.
Each header file contains function declarations along with a small description of what the function does.
Each C file contains a function that performs a specific objective.
Thus, modularity in the code is accomplished.
We now proceed to give an overview of the files:
bg_terminate.c
: This contains the handler that runs when a background process exitsexec_cd.c
: This executes the cd function of the shell.exec_echo.c
: This executes the echo function of the shell.exec_ls.c
: This executes the ls function of the shell.exec_pinfo.c
: This executes the pinfo function that prints process information.execute.c
: This contains the function that either calls a function associated with a builtin, or calls launch() to launch an external process.init.c
: Initialises the shell.launch.c
: Launches the external commands, both background and foreground.loop.c
: Contains the Read - Eval - Print loopmain.c
: Contains main function that intitialises the shell and calls loop()Makefile
: Contains rules for compiling the code.parse.c
: Parses string according to given delimiter.prompt.c
: Prints prompt for the shellREADME.md
: Contains instructions for compiling and running the code. It also contains information about the files.history.c
: Contains history function that prints historynightswatch.c
: Contains nightswatch functionshell.h
: Contains global variables used throughout many functionscountargs.c
: Contains function that counts the number of arguments from a listexec_bg.c
: Contains function that runs a stopped background processexec_jobs.c
: Lists jobs that are in the background that were started from shell.exec_kjob.c
: Function for sending a signal to a job with given job numberexec_setenv.c
: Sets an environment variable to a given valueexec_unsetenv.c
: Unsets value of given environment variableexecute_command.c
: Executes the given command, either builtin or externalexecute_pipeline.c
: Executes a piped series of commandslinkedlist.c
: Contains the implementation of the linked list used for job controloverkill.c
: Contains function that kills all background jobsquit.c
: Function to exit the shellrecall_history.c
: Implements execution of commands from history when up arrow key is pressedsighandlers.c
: Contains signal handlers for Ctrl + Z and Ctrl + C