This is a custom shell made in C. I tried to implement as many features as possible. Hope you like it.
The below points describe which file contains what type of functionality.
Before running the below commands, make sure you have
- GCC compiler
- Linux OS (prefereably Ubuntu)
Run the following commands to start the shell.
$ make
$ ./shell
-
main.c
This contains the main function of the program. The main function includes the primary shell-loop of the program and is responsible for executing other commands.
-
prompt.c
This file is responsible for implementing and printing the prompt of the shell. It also extracts the input and parse into commands broken by a semi-colon.
-
executeCommand.c
This file is responsible for handling redirection and piping.
-
stringTokenize.c
This contains the function parseString to break the strings with delimiters into respective arguments/commands.
-
cd.c
This is responsible for implementing 'cd' functionality.
-
echo.c
This is responsible for implementing 'echo' functionality.
-
pwd.c
This is responsible for implementing 'pwd' functionality.
-
ls.c
This is responsible for implementing 'ls' functionality.
-
history.c
This is responsible for implementing 'history' functionality.
-
pinfo.c
This is responsible for implementing 'pinfo' functionality which basically describes the information regarding a process.
-
otherCommands.c
This file is responsible for implementing foreground and background processes using the execvp command by forking the parent process. It includes the functions for implementing the above.
-
jobs.c
For checking the status of a background process (whether exited or not), this file uses functions that store the PID and command name of the process in an array jobList. It implements the functionality of adding and removing background processes in the jobList Array.
-
changeProcessGroup.c
This file is responsible for performing fg and bg command.
-
commandList.c
This file contains the conditional branch for selecting which command has to be executed.
-
killProcess.c
This file is responsible for performing kjob and overkill both of which are used to kill processes.
-
jobDeclaration.h
This header describes the structure job for implementing the functionality in jobs.c
-
headers.h
This includes all the header files used from C Library and some constant variables (#define). It also describes the colors used in this assignment.
-
history.txt
This file stores the history of commands ran on the shell.
-
The total no. of commands separated by semi-colon are atmost 100.
-
The length of each command is atmost 1024.
-
The total no. of background processes at any instance are atmost 50.