This is a simple UNIX command interpreter that replicates the sh program on Linux. Once installed our shell will display a prompt and wait for the user to type a command that always ends with a new line. The prompt will always be displayed after a command has been executed in order to make user experience easy. If the command cannot be executed, print error will be displayed in the terminal and the prompt will be displayed again.
Clone the repository:
$ git clone https://github.com/Dragneel0112/simple_shell.git
Change directories into the repository:
cd simple_shellCompile:
gcc -Wall -Werror -Wextra -pedantic *.c -o hshRun the shell in interactive mode:
$./hshOr run the shell in non-interactive mode:
$ echo "/bin/ls" | ./hshTo exit:
press 'Ctrl-D' or enter 'exit'The shell will function like this in interactive mode:
$ /bin/ls
hsh shell.h shell.c$ pwd
/simple_shell$ ls -l
drwxrwxr-x 7 vagrant vagrant 4096 Dec 15 11:42 hsh
-rw-rw-r-- 1 vagrant vagrant 148 Dec 15 11:42 shell.h
-rwxrw-r-- 1 vagrant vagrant 28 Dec 15 11:29 shell.cBut also in non-interactive mode:
$ echo "/bin/ls" | ./hsh
hsh main.c shell.c$ echo "pwd" | ./hsh
/simple_shellThe output of this program when executed it look like:
exit