h71 is a shell coded in C that simulates bash.Certain functions were implemented from scratch while others were implemented using the execvp()
function.
Navigate to the required directory where the files are present and run the make
command, which will produce an executable file h71
. In order to run the executable, use the command ./h71
.
Contains the declaration of all functions used across files.
Contains the declaration of all global variables
Contains all the headers used in the shell and also some buffer size limits
File that contains the main() function. Runs various initial function like signal handling. Contains indefenite while loop that callas h71_main function
Contains various helper functions that are used in order to implemnt the various specifications of the shell
Contains some auxillary functions that help with background processes and signal handling
Contains the function that parses the command based on the semi-colon and calls various functions in order to handle the parsed string
Contains the function that executes the cd
command
Contains the function that executes the pwd
command
Contains the function that executes the pinfo
command
Contains the function that executes the ls
command
Contains the function that executes the echo
command
Contains the function that executes the discover
command
Contains the function that executes the history
command. Also contains the function which writes the command to the .h71_history.txt file which is created in the home directory of the system as a hidden file by the history_init()
function.
Contains the function that processes commands that are not to be implemented via execvp and parses that string based on '&' and checks whether the command is to be execueted in the foregorund or the background
Runs the required command as a foregound process
Runs the required command as a background process
Contains the functions that handle autocomplete functionality
Contains the function that handles piping
Contains the function that handles I/O redirection
Syntax:echo <string>
Echo simply writes the given string to the terminal
Syntax:pwd
Displays the absolute path of the current working directory
Syntax:cd <arg>
arg->dirrectory name. Also supports . , .. , ~ , -
.
Changes current directory to the directory specified in the argument. If no argument is given then the current directory is changed to the home directory
Syntax:ls <flags><dir_name/file_name>
Lists all the files and directories in the specified directory. Supports -a and -l flags. If a file name is given as an argument, then information about the file itself is displayed
Syntax:discover <dir_name><flags><target_file>
Lists all the files and directories in the given directory hierarchy. Supports -f and -d flags. If a target file is given, then the command will diplay the path of the file if found.
Syntax:pinfo <pid>
Displays information about the process with the pid given as argument. Information inlcudes status code, executable path, virtual memory size and PID.
Syntax:history
Displays atmost the last 10 commands taken as input
Syntax:quit
Terminates the shell program. Aliases include q , exit
Syntax:fg <job_no>
Brings a process from the background to the foreground and changes it's status to running
Syntax:bg <job_no>
Signals a stopped background process to continue running
Syntax:sig <job_no> <sig_no>
Sends the given signal to process with the given job_no
Syntax:jobs <flags>
Outputs the list of processes (in alphabetical order) in the job pool with their status
-> Current max command length is 10^5 characters
-> If multiple forground processes are run, then the prompt will display the time taken by the foreground process that finished execueting last
-> A maximum of 1024 processes can be run in the background at any given point
-> history
command is implemented by creating a hidden file .h71_history.txt in the home file of the system and storing the previous 20 commands. The command accepts no arguments and will just return atmost the last 10 commands.