Made for an assignment/s for OS&N Course Monsoon 2022-23.
Completely coded in C
.
make
/make bbsh
(For building the executable file)make clean
(For cleaning the built files)
BB-SHELL is a very advanced noob shell, which can do some work, but very limited. 😅
It has some of the following features as of now:- (More may not come later)
- Colourful shell display with username/hostname and current directory.
- Can run some built-in commands such as
cd
,echo
,pwd
,ls
(With -a and -l flags). - Other Commands -
pinfo
(≈ ps),discover
(≈ find with -d and -f flags) - Stores
history
of upto 20, for all the sessions. - Error Handling
- Can run both
background
qandforeground
processes. (For any other shell commands) - Multiple Command Execution in a single line using
;
. exit
is used to exit the shell.- I/O Redirection using pipes and < & >/>>.
- Autocomplete file names.
- Signal Handling (Ctrl-C, Ctrl-Z, Ctrl-D)
-
Usage: cd <path_to_directory>
Supports the following wildcards:
~
: path to shell's home directory-
: path to previous directory.
: path to current directory..
: path to parent directory
-
Usage: pwd
-
Usage: echo <string>
-
Usage: ls <path_to_directory_1> <path_to_directory_2> ...
Flags:-
-a
: do not ignore entries starting with .-l
: use a long listing format
Supports all the wildcards as
cd
. -
Usage: pinfo <pid>
Gives the following info:
- Process ID
- Process Status
- Virtual Memory
- Path to Executable
-
Usage: discover <target_dir> "<file_name>"
Flags:-
-d
: searches for all directories-f
: searches for all files
All arguments/flags are optional to use.
-
Usage: exit
Alaias for
exit
->quit
-
Usage: history
Prints the last
10
commands in the history. -
Usage: jobs
- Prints a list of all currently running background processes spawned by the shell in alphabetical order of the command names.
-
Usage: sig <job id> <signal number>
- Sends a signal to the job with given id (Running in background)
-
Usage: fg <job id>
- Brings the process into foreground and set it running.
-
Usage: bg <job id>
- Sets the given id background process in running state.
-
- Runs the command in the foreground.
- If
&
is added at the end, will run the command in background.
main.c
-> Containing the parent code to run the shell. Just mainly calling different functions.libraries.h
-> Containing all the imports and in general definitions.input.c
andinput.h
-> Containing the functions to take input, process it and do tasks based on that. Also, handles the I/O Redirection processes.raw_input.c
-> Containing the functions to take raw input, also handling the autocomplete functionality.print.c
andprint.h
-> Containing the code to print prompt, errors, etc.signals.c
andsignals.h
-> Containing the functions to handle different basic signals and process them accordingly.path.c
andpath.h
-> Containing the functions to process different directories and paths.history.c
andhistory.h
-> Reading, Processing and Writing History. If want to change the path of the history file, you can use thishistory.h
file.discovery.c
anddiscovery.h
-> Handles the code fordiscovery
command and its variants.jobpool.c
andjobpool.h
-> Manages the current running processes in the shell, along with doing book-keeping for the background processes.helpers.c
andhelpers.h
-> Some basic functions for using at different places.commands1.c
,commands2.c
andcommands.h
-> Imp. functions for different commands and all of their implementations.