Minishell is a simple shell implementation project. It aims to provide a basic command-line interface similar to Bash, where users can execute commands, handle file redirection, pipelines, environment variables, and manage signals.
The mandatory part of this project implements the following core functionalities:
- Prompt: Displays a prompt when waiting for a new command.
- Command History: Maintains a history of previously executed commands.
- Executable Search: Finds and executes commands based on the
PATHenvironment variable, or using relative/absolute paths. - Global Variables: Minimizes the use of global variables, with one allowed for signaling.
- Quotes Handling:
- Single quotes (
') prevent interpretation of special characters. - Double quotes (
") prevent interpretation of special characters, except for$.
- Single quotes (
- Redirections:
<: Redirect input.>: Redirect output.<<: Implements here-document functionality.>>: Redirect output in append mode.
- Pipes (
|): Supports piping where the output of one command is used as the input to the next. - Environment Variables: Handles
$for variable expansion and$$for the exit status of the most recently executed foreground pipeline. - Signal Handling:
Ctrl-C: Interrupts and shows a new prompt.Ctrl-D: Exits the shell.Ctrl-\: Does nothing.
- Built-in Commands:
echowith the-noption.cdwith relative or absolute paths.pwdto print the working directory.exportfor managing environment variables.unsetfor removing environment variables.envto display the current environment variables.exitto close the shell.
- C Language: The project is written in C and adheres to the 42 Norm.
- Memory Management: All allocated memory is freed when necessary; no leaks are tolerated except those from the
readline()function. - Makefile: A Makefile is included to compile the project using the flags
-Wall -Wextra -Werrorwithout relinking. The rules include:all: Compiles the program.clean: Removes object files.fclean: Removes all generated files.re: Rebuilds the project.
To compile the project:
makeTo run the shell:
./minishellvalgrind --leak-check=full -q ./minishell