Minishell is one of the two project in the 42 program fourth circle. This is the first group project of the 42 common core program. In this projects the students need to create their own shell basec on sh.
According to the subject there only one constraint for this project:
- The whole files of the projects need to follow 42 norm [Link]
Here are the external functions allowed for this project:
| add_history | printf | malloc | fork | wait | waitpid |
| free | write | access | wait3 | wait4 | signal |
| open | read | close | sigaction | sigemptyset | sigaddset |
| kill | exit | rl_replace_line | readline | rl_clear_history | rl_on_new_line |
| getcwd | chdir | stat | lstat | fstat | unlink |
| execve | dup | dup2 | pipe | opendir | readdir |
| closedir | strerror | perror | isatty | ttyname | ttyslot |
| ioctl | getenv | tcsetattr | tcgetattr | tgetent | tgetflag |
| tgetnum | tgetstr | tgoto | tputs |
Our group splitted the workload in 2 parts:
- The input parsing handled by GreenPG.
- The remainings features (creation and/or execution of commands, signal management, etc.) was handled by myself.
In the following array a list of the features requested by the subject:
| Name | Descripion | status |
|---|---|---|
| Prompt | Display a prompt when waiting for a new command | ✅ |
| History | Have a working input history | ✅ |
| PATH | Search and launch the right executable (based on the PATH variable or using a relative or an absolute path). | ✅ |
| ' | Handle single quote | ✅ |
| " | Handle double quote | ✅ |
| | | The output of each command in the pipeline is connected to the input of the next command via a pipe. | ✅ |
| Env Variable | Handle environment variables ($ followed by a sequence of characters) which should expand to their values. | ✅ |
| $? | Have a working input history | ✅ |
| Redirections | ||
| < | Should redirect input. | ✅ |
| << | Should redirect output. | ✅ |
| > | Should be given a delimiter, then read the input until a line containing the delimiter is seen. However, it doesn’t have to update the history! | ✅ |
| >> | Should redirect output in append mode. | ✅ |
| Signaux | ||
| ctrl-C | Displays a new prompt on a new line. | ✅ |
| ctrl-D | Exits the shell. | ✅ |
| ctrl-\ | Does nothing. | ✅ |
| Builtins | ||
| echo | echo with option -n | ✅ |
| cd | cd with only a relative or absolute path | ✅ |
| pwd | pwd with no options | ✅ |
| export | export with no options | ✅ |
| unset | unset with no options | ✅ |
| env | env with no options or arguments | ✅ |
| exit | exit with no options | ✅ |
In the following array a list of the bonus features requested by the subject:
| Name | Descripion | status |
|---|---|---|
| && | With parenthesis for priorities. | ❌ |
| || | With parenthesis for priorities | ❌ |
| Wildcards | Should work for the current working directory. | ❌ |
make to compile.
clean to clean all compiled file without the library file.
fclean to clean all compiled file with the library file.
re to fclean then make.