A Basic and Simple Shell written in C
1. Fork the repo & cd into the correct directory
2. Run the command 'make'
3. The makefile will create the cshell executable file
4. Run './cshell' to start the shell
5. If you face any issues, run the command 'make clean'.
This removes old executables. Then run 'make' to compile all the files again
and finally run './cshell'
The prompt of this shell is in the following format:-
[system name]:~ [absolute path of the current directory] >>
ex: sripad:~ /home/folder1>>
- pwd : prints current working directory
- cd : For changing directory
Example:cd path
This chamges the current working directory to 'path.' - about :
Shows basic details about this shell - help :
shows help text about basic inbuilt commands - history :
Gives list of recently ran commands
Note: Recent commands can be ran again by entering!num
. This will run the numth command from history.
Example:- Suppose output of history is as follows:-
1 ls
2 pwd
3 about
4 help
Thepwd
command can be ran again by running !2 in the shell - jobs :
Lists all the processes running in the background. Processes can be run in the background by adding '&' at the ending of commands. There must be a white-space between '&' and the command. - kill <pid> : kills the process with pid = <pid>
- exit : exits the shell cleanly
- This shell also supports user commands.
- User command can be pushed to the background by adding '&' at the end of command.
- The stdin and stdout can also be redirected by using '> filename' and '< filename'
- Note:- There must be a single white space between > or < and the filename. Example:- ./prog > op.txt < ip.txt This command causes the program to take input from tmp.txt and prints the output to op.txt.
- Add '|' Pipe handling