A basic C shell
The project contains the following folder with files described:
- build: stores the build files
- include: stores all header files
- src: stores
.c
source code files
-
Make sure you have a build folder in the current directory. If not then create by
mkdir build
To build normally
make
To build with debugging on
make debug
NOTE: All the build files will be in the build folder
-
./gSH
-
make clean
globals.h
: File with global variable, structs and header files declarations.
The following files are in src
directory. The corresponding .h
files can be found in include
directory. .h
files also contain brief description.
main.c
: File withmain()
.Calls init ,repl and destroy functions. (This file does not has a corresponding.h
file)parse.c
: File with functions to take raw input string and parse it.First seperates at";"
forPipedCommands
struct then seperates at"|"
to extractCommand
and returns a structParsedCommands
with all neccessary things.shell.c
: File with init, repl, byebye function. This also has function to executeParsedCommands
using corresponding executorprompt.c
: File with function to return prompt string.cd.c
: File with cd command implementation and executorecho.c
: File with echo command implementation and executorls.c
: File with ls command implementation and executormpwd.c
: File with pwd command implementation and executorpinfo.c
: File with pinfo command implementation and executorerrorHandler.c
: File with error handlers for syscallshistory.c
: File with history command implementation and executor. This file also contains functions to add a command to history, save history and load historysysCommand.c
: File with function for execution of non-builtin commands in foreground or backgroundsignalHandlers.c
: File with signal handlers.utils.c
: File with some utility functionsbg.c
: File with bg functionalityenv.c
: File with some setenv and unsetenv optionfg.c
: File with fg command implementation and executorjobs.c
: File with jobs command implementation and executorkjob.c
: File with kjob command implementation and executoroverkill.c
: File with overkill command implementation and executorpiping.c
: File with funciton to execute piped commands inPipedCommands
struct by making pipes between consecutive processes.processList.c
: File with functions to handle background process linked list.redirecting.c
: File with 2 functions 1st to start I/O redirection and 2nd to restore all STDIN and STDOUT.