This project is about creating a simple shell. Our own little bash with limited functionalities.
Team project with Orezek at 42Prague.
- displays prompt as a bash - with path to current directory
- working history
- working redirections (
<
,>
,>>
), heredoc (<<
), pipes (||
) - execute commands as bash with argumets -
ls
,cat
,head
,git
... - launch executables - try launch
./minishell
in./minishell
- handle environmental variables
- woking expansion of environmental variables ($) as bash
- handle CTRL-C, CTRL-D, CTRL-\ as bash
- working builtins:
echo
with option-n
cd
with only a relative or absolute pathpwd
with no optionsexport
with no optionsunset
with no optionsenv
with no options or argumentsexit
with no options
- Cannot handle open quotes or open double quotes
- Cannot handle special characters such as backslash \ or semicolon ;
- NO BONUS - Cannot handle &&, || and wildcards *
- You have to have readline installed. If not, install it with
sudo apt install libreadline-dev
- Make the minishell with command
Make
- Run the program
./minishell
cat | cat
- should hang and after pressing CTRL+C should end execution and show prompt again
cat /dev/urandom | head -5
/bin/ls src
/bin/pwd hello
/bin/date
/usr/bin/head -n 10 Makefile
/bin/grep # Makefile
/usr/bin/uname -a
/usr/bin/head Makefile
/usr/bin/tail Makefile
Use this prompt to check for leaks, open fds, etc. (It requires minishell.supp file in minishell root directory)
valgrind -s --leak-check=full --show-reachable=yes --error-limit=no --suppressions=minishell.supp --trace-children=yes --track-fds=yes ./minishell
-s
same as --show-error-list=yes that shows detected errors list and suppression count at exit--leak-check=full
shows a full list of memory leaks--show-reachable=yes
same as--show-leak-kinds=all
that shows all kinds of memory leaks--error-limit=no
won't stop showing errors if too many--suppressions=minishell.supp
suppresses memory leaks from in-built functions (readline and add_history)--trace-children=yes
checks memory leaks in child process too--track-fds=yes
tracks open and closed file descriptors
- Understand bash better, how it works underneath
- Better understanding of processes, forks, wait, waitpid, exit statuses, etc.
- Learned what signals are and how to handle them
- Learned to use static variable within clean functions to store a pointer to a struct for later use (see for example the exit_minishell() function)
- Become more familiar with structs and linked lists
- m-bartos - parser - splitter, expander, heredoc; prompt construction
- orezek - execution, built-ins, signals, environmental variables
- Thanks LukasKuhn for the minishell tester
- Appreciate the project discussions, testing and hints provided by our fellow 42Prague students - andreaulicna, loudapet - Thanks you for your insights!