A hell project from 42
- Interactive shell with basic prompt functionality
- Execution of binary commands (e.g.,
/bin/ls) - Built-in commands:
cd: Change the current working directoryecho: Display a line of textenv: Show environment variablesexit: Exit the shellexport: Set environment variablespwd: Print the current directoryunset: Remove environment variables
- Input and output redirection (
<,>,>>) - Support for pipes (
|) to chain commands - Signal handling for
Ctrl+C,Ctrl+D, andCtrl+Z - Environment variable expansion (e.g.,
$PATH,$HOME) - Error handling for invalid commands or syntax
/minishell
├───inc
| ├───ft_printf.h
| ├───get_next_line.h
| ├───libft.h
| └───minishell.h
├───libft
| └───...//soon will publish libft libraries
├───shell
| ├───builtins
| | ├───cd.c
| | ├───echo.c
| | ├───env.c
| | ├───exit.c
| | ├───export.c
| | ├───pwd.c
| | └───unset.c
| ├───env
| | ├───env.c
| | ├───get.c
| | ├───shlvl.c
| | └───sort.c
| ├───exec
| | ├───bin.c
| | ├───builtin.c
| | └───cmd.c
| ├───parse
| | ├───expansion.c
| | ├───line.c
| | ├───token.c
| | └───token_data.c
| └───utils
| ├───expansion.c
| ├───fd.c
| ├───free.c
| ├───gnl.c
| ├───minishell.c
| ├───parse.c
| ├───token.c
| ├───type.c
| └───utils.c
├───src
| ├───main.c
| ├───rd_cmd.c
| └───signalling.c
├───Makefile
└───README.md
- Understanding process creation and management (fork, execve, wait, pipe)
- Mastering file I/O and redirections
- Implementing a custom shell environment
- Handling user input and signal interruptions
@nizarsyahmi37 - Main contributor, bash interface designer @ninetendo59 - Create minishell "skeletal" structure, norminette checking, debugging completed code (fixing leaks, uninitialised value, refactor and restructure code), sanity testing.
- A window or interface that provides a space to execute commands via a shell.
- Acts as a container for the shell to run.
- It is a command interpreter or environment where you execute commands.
- Offers scripting, command history, and access to system features.
| Function | Pros | Cons |
|---|---|---|
get_next_line(int fd)
|
|
|
readline (const char *prompt) |
|
|
- In my opinion, using
readline()is the easiest way to complete your minishell compared toget_next_line(). - If you are perfectionist, why not just go ahead to use
get_next_line()?
valgrind --leak-check=full ./minishell
- https://m4nnb3ll.medium.com/minishell-building-a-mini-bash-a-42-project-b55a10598218
- https://www.youtube.com/watch?v=yTR00r8vBH8
- https://medium.com/@muxanz/how-the-shell-works-internally-when-entering-a-command-42f08458870
- https://medium.com/@nyangaresibrian/simple-shell-b7014425601f
- https://42-cursus.gitbook.io/guide/rank-03/minishell