This is the repository for 42's Minishell project made by @ku-alexej and @marinsucks.
Minishell is a simplified version of a shell, implementing some of the basic functionalities of the Bash POSIX shell. It supports executing commands, handling environment variables, basic and managing processes.
Minishell supports the following features:
-
Command Execution: commands can be executed with or without arguments from absolute and relative paths as well as directories included in the
PATH
environment variable. -
Signal Handling:
- ctrl-C displays a new prompt on a new line.
- ctrl-D exits the shell.
- ctrl-\ does nothing.
-
Environment Variables: Environment variables can be used in any command as
$
followed by the variable name. They can be manipulated using theexport
andunset
builtins. These variables are inherited from the parent process and sent to the child processes.$?
, which expands to the exit status of the last executed command, is also supported. -
Quoting: Minishell handles single quotes
'
and double quotes"
which prevent the shell from interpreting the meta-characters in the quoted sequence, except for environment variables inside double quotes (echo "$USER"
prints the username, whileecho '$USER'
simply prints $USER). -
Redirections and Pipes:
<
for input<<[delimiter]
for reading input until a line containing the delimiter is seen>
for output>>
for appending output.|
for the pipe, where the output of the left command is sent to the input of the right command.
-
echo
prints its arguments followed by a newline. The-n
option suppresses the newline at the end.cd
changes the current directory and accpets absolute and relative paths.pwd
prints the current working directory.export
sets its arguments to environment variables, or prints all environment variables if no argument is provided.unset
removes the specified environment variables.env
prints the environment variables which values aren't NULL.exit
terminates the process with the specified exit code.
To get started with Minishell, follow these steps:
-
Clone the repository:
git clone https://github.com/ku-alexej/minishell.git; cd minishell
-
Build the project:
make
-
Run Minishell:
./minishell
The project uses the readline
library for line editing. Functions from this library can cause memory leaks when used with valgrind
. To avoid this, run the program with the following command from the project's root directory:
valgrind --suppressions=$PWD/readline.supp ./minishell