Note: This shell code has been written to be run on a computer with the Microsoft Windows Operating System. Commands are likely to not run on other operating systems.
- C Shell
- Open your preferred terminal which can detect the
gcc
command. - Navigate to the current
c-shell
folder. - Run the
make all
command. - Open the shell using
./shell.exe
.- Alternatively, you can also double click and run the executable file.
- To clear the files, run
make clear
.- Note: A helper file named
cmd_hist.txt
is created in the user'sDocuments
folder on the first run of the shell, which does not get automatically deleted when themake clear
command is run.
- Note: A helper file named
Prints back the user input with formatting if necessary.
Note: Even though the shell is configured to run in Windows OS, the echo
command is designed to simulate the functioning of echo
in a Linux environment.
echo <prompt>
echo "<prompt_line_1>
> <prompt_line_2>
> ..."
- Truncates extra white spaces.
- Handling of quotes, i.e. when a double quote is started, characters are read as is without any truncation/modification until double quotes are closed.
- If a user starts a double quote and enters a new line, then they cannot cancel the new line.
- Cannot parse escape sharacters such as
\b
,\t
,\r
, etc. if entered manually as text in the prompt.
<USERNAME@WINDOWS:~> echo Hi!
Hi!
<USERNAME@WINDOWS:~>
<USERNAME@WINDOWS:~> echo Hi! "My name is:
> FirstName LastName." Nice to meet you!
Hi! My name is:
FirstName LastName. Nice to meet you!
<USERNAME@WINDOWS:~>
Prints the current working directory of the shell.
pwd
<USERNAME@WINDOWS:~> pwd
C:\Users\USERNAME
<USERNAME@WINDOWS:~>
Navigates to the specified directory.
cd <prompt>
- Parses special inputs such as
.
,..
,-
,~
and empty input. - Remembers the entire history of changes in directory in a shell session.
- Can handle nested directories.
- Cannot navigate to directories which have spaces in their name, regardless of the presence of double quotes.
- Cannot navigate above the home directory.
- If an error occurs in the middle of executing a nested file path, then the shell's working directory is set to the sub-path till which execution was successful.
<USERNAME@WINDOWS:~> cd .
<USERNAME@WINDOWS:~> cd folder
<USERNAME@WINDOWS:~\folder> cd
<USERNAME@WINDOWS:~> cd -
<USERNAME@WINDOWS:~\folder> cd ~
<USERNAME@WINDOWS:~> cd folder/nested_folder_1/
<USERNAME@WINDOWS:~\folder\nested_folder_1> cd ../nested_folder_2
<USERNAME@WINDOWS:~\folder\nested_folder_2>
<USERNAME@WINDOWS:~> cd folder
<USERNAME@WINDOWS:~\folder> cd nested_folder_1
<USERNAME@WINDOWS:~\folder\nested_folder_1> cd ../nested_folder_2
<USERNAME@WINDOWS:~\folder\nested_folder_2> cd -
<USERNAME@WINDOWS:~\folder\nested_folder_1> cd -
<USERNAME@WINDOWS:~\folder> cd -
<USERNAME@WINDOWS:~>
Lists the history of commands previously run on the shell across sessions.
history
<USERNAME@WINDOWS:~> echo Hi!
Hi!
<USERNAME@WINDOWS:~> pwd
C:\Users\USERNAME
<USERNAME@WINDOWS:~> echo Greetings.
Greetings.
<USERNAME@WINDOWS:~> echo Hello!
Hello!
<USERNAME@WINDOWS:~> history
echo
pwd
echo
history
<USERNAME@WINDOWS:~> exit
Upon running the shell again,
<USERNAME@WINDOWS:~> history
echo
pwd
echo
history
exit
history
<USERNAME@WINDOWS:~>
Exits the shell.
exit
c-shell
|_cd_code
|_cd.c
|_cd.h
|_echo_code
|_echo.c
_|echo.h
|_pwd_code
|_pwd.c
|_pwd.h
|_shell_code
|_shell.c
.gitignore
makefile
README.md
The *_code
folders, where *
is a placeholder for the command name, contain the files specifying the declarations and definitions of the functions of the respective commands.
The .gitignore
file is for specifying the files to ignore if a git repository is initialised in the folder.
The makefile
file contains the commands for compilation and deletion of the shell.
The README.md
file contains the compilation instructions, description of the commands and the file structure.