The first group project at 42Berlin, my teammate Zaperfish.
The subject requires you to create your own representation of a shell.
While testing, for the most part, we based it on bash.
This one was one of the most challenging projects through-out my curriculum, mostly because of the many edge-cases this program presented.
the subject is included in ./en.subject.pdf
The existence of shells is linked to the very existence of IT.
At the time, all developers agreed that communicating with a computer using aligned 1/0 switches was seriously irritating.
It was only logical that they came up with the idea of creating a software to communicate with a computer using interactive lines of commands in a language somewhat close to the human language.
Thanks to Minishell, you’ll be able to travel through time and come back to problems people faced when Windows didn’t exist.
git clone https://github.com/VulpesDev/Mini-shell.git ~/minishellVulpes && cd ~/minishellVulpes && make && ./minishell
Upon running the executable you will be prompted to
DEATH....>
Congratulations, you are now using our shell. From here on you can play around with it and use it as your system's default shell (I highly recommend against it... ha ha ha)
- Working history (whenever you type something in the prompt (and press enter), you can turn back time (up arrow) and get it back in the promt, how cool...)
- Search and launch the right executable (based on the PATH variable or using a relative or an absolute path)
- Handle unclosed quotes and dquotes
- Handle '(single quote) which should prevent the shell from interpreting the meta-characters in the quoted sequence
- Handle "(double quotes) which should prevent the shell from interpreting the meta-characters in the quoted sequence except for $(dollar sign)
- Implement redirections:
- < should redirect input.
- > should redirect output.
- << should be given a delimiter, then read the input until a line containing the delimiter is seen.
- < should redirect output in append mode.
<input.txt wc -l >output.txt
(this requires an existing file input.txt) should create/edit a file output.txt changing its contents to the number of lines in input.txt
- Implement pipes(| character). The output of each command in the pipeline is
connected to the input of the next command via a pipe.
(I hope you still have the input.txt)
cat input.txt | wc -l | cat -e
- Handle environment variables($ followed by a sequence of characters) which should expand to their values.
echo $PATH
env
(to show the environment variables)
- Handle $? which should expand to the exit status of the most recently executed foreground pipeline.
- Handle ctrl-C, ctrl-D and ctrl-\ which should behave like in bash.
- Implement the following builtins:
- echo with option -n
- cd with only a relative or absolute path
- pwd with no options
- export with no options
- unset with no options
- env with no options or arguments
- exit with no options
- && and || and parenthesis for priorities.
- Wildcards * should work for the current working directory.
DEATH....>ls
DEATH....>/usr/bin/ls
echo 'hello this pipe should just print as a pipe | as well as all those symbols <>()""(")""$USER$$$$$$$PATH'
echo "hello this pipe should just print as a pipe | as well as all those symbols <>()''''''(')'' but replace this $USER with the actual user"
echo $?
yes | head -10 && (eewqr wrqwr || echo t) && (echo pow && (echo 2 && echo 3) || edwadw) > outfile.txt