Score | Duration | Peer(s) |
---|---|---|
✅ 125 / 100 | 🕓 8 week(s) | 👷🏻 Yes |
This team project is a program that reproduces the bash
shell. It includes prompt, persistent history, several builtins, full support for quotes (double and single), redirections and piping, shell variables and environment variables and their expansion, signal processing, support for logical operators, subshells and wildcards.
- Display a prompt while waiting for an input.
- Search order for binaries identical to
bash
. - Executes the correct binaries.
- Supports session history.
- Supports persistent history (file storage).
- Implements builtins
echo
,cd
,pwd
,export
,unset
,env
andexit
.
- Supports simple quotes
''
and double quotes""
. - Supports unclosed double quotes.
- Supports unclosed simple quotes.
- Supports pipe
|
redirections. - Supports
<
,>
and>>
file redirections. - Supports heredoc
<<
redirections. - Supports herestring
<<<
redirections.
- Supports environment variables.
- Supports shell variables.
- Shell variables can be exported with
export
. - Supports variable
$?
.
- Supports signals
CTRL-C
,CTRL-D
andCTRL-\
in passive and interactive mode.
- Supports logical operators
&&
and||
.
- Supports the execution of subshells in parentheses
()
.
- Supports token
;
as delimiter. - Supports incomplete lines ending with
|
,&&
or||
.
- Supports wildcard
*
in the basename of any absolute or relative path.
- Supports inline comments with token
#
.
sudo apt -y install clang-12 make libreadline-dev
1. Get the project
git clone https://github.com/Vlad-PLK/MINISHELL.git
2. Build the project
make -j$(nproc)
🔵 Info: The
minishell
executable will be created in the project root directory.
3. Run the project
./minishell
Double quotes:
minishell$ echo "Like a shell: $SHELL"
Like a shell: 42-minishell/minishell
Simple quotes:
minishell$ echo 'Like a shell: $SHELL'
Like a shell: $SHELL
Unclosed quotes:
minishell$ echo "Hello
> world!"
Hello
world!
Pipe redirection:
minishell$ echo "Hello world!" | cat --number
1 Hello world!
File redirection:
minishell$ echo "Hello world #1" > a.txt
minishell$ echo "Hello world #2" >> a.txt
minishell$ cat --number < a.txt
1 Hello world #1
2 Hello world #2
Heredoc:
minishell$ cat << DEL
> Hello
> world!
> DEL
Hello
world!
Herestring:
minishell$ cat <<< "Hello world!\n"
Hello world!
Environment variables:
minishell$ export A="Hello world!"; echo $A
Hello world!
Shell variables:
minishell$ A="Hello world!"; echo $A
Hello world!
Logical operators:
minishell$ echo "A" && echo "B" || echo "C" && echo "D"
A
B
D
Subshell:
minishell$ echo "A" && echo "B" || (echo "C" && echo "D")
A
B
Delimiters:
minishell$ echo Hello; echo world!
Hello
world!
Incomplete lines:
minishell$ echo "Hello world!" |
> wc -w
2
minishell$ echo -n "Hello " &&
> echo "world!"
Hello world!
minishell$ echo "Hello " ||
> echo "world!"
Hello
Wildcards:
minishell$ echo includes/m*.h
includes/minishell.h
Comments:
minishell$ echo "Hello world!" # It's an inline comments!
Hello world!
Rule | Action |
---|---|
all | Compile. |
clean | Delete all generated object files |
fclean | Apply clean , lclean and delete the executable. |
lclean | Apply fclean to all used libraries. |
re | Apply fclean and force recompile. |