https://github.com/hamaarour/minishell
This project is about creating a simple shell - essentially, my own little bash. Through this project, I've learned a lot about processes and file descriptors.
https://github.com/hamaarour/minishell
1337cursus 1337school bash c minishell42
Last synced: 6 months ago
JSON representation
This project is about creating a simple shell - essentially, my own little bash. Through this project, I've learned a lot about processes and file descriptors.
- Host: GitHub
- URL: https://github.com/hamaarour/minishell
- Owner: Hamaarour
- Created: 2023-04-06T00:16:02.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-06-06T19:39:58.000Z (over 2 years ago)
- Last Synced: 2025-02-14T17:38:36.730Z (8 months ago)
- Topics: 1337cursus, 1337school, bash, c, minishell42
- Language: C
- Homepage:
- Size: 5.34 MB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
![]()
![]()
This project is about creating a simple shell
MiniShell will introduce you to the world of shells, which provide a convenient text interface to interact with your system. Shells might seem very easy to understand but have very specific and defined behaviour in almost every single case, most of which will need to be handled properly
## The Challenge
This was probably the biggest project I've done so far, as well as the first one I did as a group. The goal was to create a mini version of bash, I say mini but it was still a huge project. We had to learn how bash takes arguments, parses them, and executes them. We had to incorporate the following features:
- Display a promt while waiting for a new commmand.
- Have a working history.
- Find and launch executables (using the `PATH` variable or an absolute path).
- Handle `'` (single) and `"` (double) **quotes** like in bash.
- Implement **redirections** such as:
- `<` redirect input.
- `>` redirect output.
- `<<` heredoc (doesn't affect history).
- `>>` redirect output in append mode.
- Implement `|` (**pipes**).
- Handle **environment variables**.
- Handle `$?`.
- `ctrl-C`, `ctrl-D`, and `ctrl-\` should behave like in bash.
- Recreate the following **builtins**:
- `echo` with option `-n`.
- `cd` with only a relative or absolute path.
- `pwd` (no flags).
- `export` (no flags).
- `unset` (no flags).
- `env` (no flags or arguments).
- `exit` (no flags).
## Installation
### Clone the repository:
```
git clone https://github.com/Hamaarour/minishell.git
cd minishell
make
```
### Run Minishell
```
./minishell
```### Some commands to try:
As this project is made to mimic bash, you can try any commands you normally would try in bash.
If you really can't think of anything try some of the following. You do have to enter each line separately as the program doesn't handle new lines.
```
ls -la | grep a | tr 'a-z' 'A-Z'
``````
cat << EOF > file
cat file
rm file
``````
ls | rev > file
cat file
rev file | cat
rm file
```*to exit the program:*
```
exit
We didn't have to implement && and ||, or wildcards, as well as any special symbols that weren't specifically asked for. We were also told that when in doubt, take bash as a reference. This sometimes led to discussions on wether or not we had to implement something, the result of which was usually