https://github.com/xdec0de/42minishell
[42] Our own simple shell based on bash, made in C
https://github.com/xdec0de/42minishell
42 42born2code 42cursus 42madrid 42projects 42school minishell minishell-42 minishell42
Last synced: 2 months ago
JSON representation
[42] Our own simple shell based on bash, made in C
- Host: GitHub
- URL: https://github.com/xdec0de/42minishell
- Owner: xDec0de
- License: mit
- Created: 2024-04-03T11:34:43.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2025-07-30T16:18:19.000Z (10 months ago)
- Last Synced: 2025-10-30T02:52:00.162Z (7 months ago)
- Topics: 42, 42born2code, 42cursus, 42madrid, 42projects, 42school, minishell, minishell-42, minishell42
- Language: C
- Homepage:
- Size: 284 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 42minishell   
42 project "minishell", code follows the norm used at 42. The objective of
this project is to create a basic replica of a bash shell, built in C.
Detailed code quality and coverage stats can be found
[here](https://app.codacy.com/gh/xDec0de/42minishell).
## Requirements
This project is designed to work on Linux. Don't expect it to work on
Windows unless you are using WSL. That being said, it still has some
requirements.
### Fast setup
A bash script is provided to install all required dependencies. You can
run it with `sudo ./setup`. This script **does require sudo or root**
privileges to run, as it uses apt to install dependencies. It will also
compile the project with `make` and has two flags to choose from:
| Flag | Description |
| :---: | :---: |
| -y | Automatically accepts installing dependencies |
| -optional | Install optional dependencies too (List below) |
If you are just testing the project and not planning to contribute to it,
then the recommended command is `sudo ./setup -y`
### List of dependencies
If you prefer a manual install, then here is the list of dependencies:
Required:
- The project compiles with `cc`.
- The readline library. Install it with `sudo apt-get install libreadline-dev`.
- Makefile is used for build logic: `sudo apt install make`.
Optional:
- [Norminette](https://github.com/42School/norminette) is used for code style
validation.
- [Valgrind](https://valgrind.org) used for leak testing.
- [lcov](https://github.com/linux-test-project/lcov),
for code coverage reports: `sudo apt install lcov`
## Building, validating and testing the project
As previously stated, 42minishell follows the norm used at 42. This means
the norminette program is used in order to validate that the code style
of the project is up to standards. To build, validate and test the project
we use Makefile. Here is the full table of commands:
| Command | Description |
| :---: | :---: |
| `make norm` | Executes norminette on the src folder for style validation |
| `make` or `make all` | Compiles updated files only |
| `make re` | Recompiles the whole project (src) |
| `make build` | `make norm` and `make re` |
| `make testonly` | `make fclean` and run tests |
| `make covonly` | Generate coverage report, assuming tests have been done |
| `make test` | `make norm` and `make testonly` |
| `make testcov` | `make testonly` and `make covonly` |
| `make clean` | Removes any file generated by these commands |
| `make fclean` | `make clean`, also removing program executables |
## Allowed functions
For this rather complex task, we are allowed to use the following table of
functions:
| Name | Library | Basic description | Used |
| :---: | :---: | :---: | :---: |
| [readline](https://linux.die.net/man/3/readline) | readline/readline.h | Get a line from a user with editing | ✅ |
| [rl_clear_history](https://tiswww.case.edu/php/chet/readline/readline.html#index-rl_005fclear_005fhistory) | readline/readline.h | Clear history list | ❌ |
| [rl_on_new_line](https://tiswww.case.edu/php/chet/readline/readline.html#index-rl_005fon_005fnew_005fline) | readline/readline.h | Move onto a new line with prompt displayed | ✅ |
| [rl_replace_line](https://tiswww.case.edu/php/chet/readline/readline.html#index-rl_005freplace_005fline) | readline/readline.h | Replace the contents of the rl_line_buffer | ✅ |
| [rl_redisplay](https://tiswww.case.edu/php/chet/readline/readline.html#index-rl_005fredisplay) | readline/readline.h | Update the display of rl_line_buffer | ✅ |
| [add_history](https://linux.die.net/man/3/history) | readline/history.h | Place a string at the end of history list | ✅ |
| [printf](https://linux.die.net/man/3/printf) | stdio.h | Formatted output conversion | ✅ |
| [malloc](https://linux.die.net/man/3/malloc) | stdlib.h | Allocate dynamic memory | ✅ |
| [free](https://linux.die.net/man/3/free) | stdlib.h | Free dynamic memory | ✅ |
| [write](https://linux.die.net/man/3/write) | unistd.h | Write on a file | ❌ |
| [access](https://linux.die.net/man/2/access) | unistd.h | Check real user's permissions for a file | ❌ |
| [open](https://linux.die.net/man/3/open) | fcntl.h | Open a file | ❌ |
| [read](https://linux.die.net/man/3/read) | unistd.h | Read from a file | ❌ |
| [close](https://linux.die.net/man/2/close) | unistd.h | Close a file descriptor | ❌ |
| [fork](https://linux.die.net/man/2/fork) | unistd.h | Create a child process | ❌ |
| [wait](https://linux.die.net/man/2/wait) | sys/wait.h | Wait for process to change state | ❌ |
| [waitpid](https://linux.die.net/man/2/waitpid) | sys/wait.h | Wait for process to change state | ❌ |
| [wait3](https://linux.die.net/man/2/wait3) | sys/wait.h | Wait for process to change state, BSD style | ❌ |
| [wait4](https://linux.die.net/man/2/wait4) | sys/wait.h | Wait for process to change state, BSD style | ❌ |
| [signal](https://linux.die.net/man/2/signal) | signal.h | ANSI C signal handling | ✅ |
| [sigaction](https://linux.die.net/man/2/sigaction) | signal.h | Examine and change a signal action | ❌ |
| [kill](https://linux.die.net/man/3/kill) | signal.h | Send a signal to a process or a group of processes | ❌ |
| [exit](https://linux.die.net/man/3/exit) | stdlib.h | Cause normal process termination | ✅ |
| [getcwd](https://linux.die.net/man/3/getcwd) | unistd.h | Get current working directory | ✅ |
| [chdir](https://linux.die.net/man/2/chdir) | unistd.h | Change working directory | ✅ |
| [stat](https://linux.die.net/man/2/stat) | unistd.h | Get file status | ❌ |
| [lstat](https://linux.die.net/man/2/lstat) | unistd.h | Get file status | ❌ |
| [fstat](https://linux.die.net/man/2/fstat) | unistd.h | Get file status | ❌ |
| [unlink](https://linux.die.net/man/2/unlink) | unistd.h | Delete a name and possibly the file it refers to | ❌ |
| [execve](https://linux.die.net/man/2/execve) | unistd.h | Execute a program | ✅ |
| [dup](https://linux.die.net/man/2/dup) | unistd.h | Duplicate a file descriptor | ❌ |
| [dup2](https://linux.die.net/man/2/dup2) | unistd.h | Duplicate a file descriptor | ❌ |
| [pipe](https://linux.die.net/man/2/pipe) | unistd.h | Create pipe | ❌ |
| [opendir](https://linux.die.net/man/3/opendir) | dirent.h | Open a directory | ❌ |
| [readdir](https://linux.die.net/man/3/readdir) | dirent.h | Read a directory | ❌ |
| [closedir](https://linux.die.net/man/3/closedir) | dirent.h | Close a directory | ❌ |
| [strerror](https://linux.die.net/man/3/strerror) | string.h | Return string describing error number | ❌ |
| [perror](https://linux.die.net/man/3/perror) | errno.h | Print system error message | ✅ |
| [isatty](https://linux.die.net/man/3/isatty) | unistd.h | Test whether a file descriptor refers to a terminal | ❌ |
| [ttyname](https://linux.die.net/man/3/ttyname) | unistd.h | Return name of a terminal | ❌ |
| [ttyslot](https://linux.die.net/man/3/ttyslot) | unistd.h | Find the slot of the current user's terminal in some file | ❌ |
| [ioctl](https://linux.die.net/man/2/ioctl) | sys/ioctl.h | Control device | ❌ |
| [getenv](https://linux.die.net/man/3/getenv) | stdlib.h | Get an environment variable | ❌ |
| [tcsetattr](https://linux.die.net/man/3/tcsetattr) | unistd.h | Set terminal attributes | ❌ |
| [tcgetattr](https://linux.die.net/man/3/tcgetattr) | unistd.h | Get terminal attributes | ❌ |
| [tgetent](https://linux.die.net/man/3/tgetent) | term.h | Load entry | ❌ |
| [tgetflag](https://linux.die.net/man/3/tgetflag) | term.h | Get boolean entry | ❌ |
| [tgetnum](https://linux.die.net/man/3/tgetnum) | term.h | Get numeric entry | ❌ |
| [tgetstr](https://linux.die.net/man/3/tgetstr) | term.h | Get string entry | ❌ |
| [tgoto](https://linux.die.net/man/3/tgoto) | term.h | Instantiate parameters into a given capability | ❌ |
| [tputs](https://linux.die.net/man/3/tputs) | term.h | Retrieve capabilities | ❌ |