Welcome to Minihell, your very own journey into the magical world of command-line interfaces! 🌟 Imagine it as your personal little bash, crafted from scratch, and, like all things small and wonderful, it’s as beautiful as a shell.
Minihell is a project that lets you create a basic yet functional shell, akin to the one you use every day but with a twist: it’s your creation! You’ll dive deep into the inner workings of processes, file descriptors, and command execution. By the end of this adventure, you’ll have your own shell that mimics many of the features of bash, but with your unique touch.
Once upon a time, developers communicated with computers by flipping 1/0 switches. This wasn’t just tedious—it was downright frustrating! So, they invented something more human: the shell. It allowed them to interact with computers using commands typed in plain (well, sort of) English. With Minihell, you’ll step into their shoes, tackling the challenges they faced before the days of Windows and fancy GUIs.
Your task is to create a shell that can:
-
Display a Prompt: When it’s time for a new command, your shell will await politely.
-
Handle History: Like a good friend, your shell remembers what you’ve said before.
-
Execute Commands: Whether it’s finding an executable in your PATH or running something by absolute or relative path, your shell’s got you covered.
-
Signal Handling: It’s tough to avoid global variables, but try to use just one for signal handling. It’s like a tiny flag your shell waves when something important happens.
-
Quotes and Meta-Characters: Your shell understands the power of quotes (single
'
and double"
), and it won’t misinterpret them. -
Redirections:
<
,>
,<<
, and>>
– these symbols have special meanings, and your shell knows them all. -
Pipes: Your shell will expertly pass the output of one command to the input of another, just like bash.
-
Environment Variables:
$VARIABLES
are magical tokens that your shell will expand to their corresponding values. -
Exit Status:
$?
tells the story of the last command’s success or failure. -
Interactive Mode: In the heat of command-line battle, your shell handles ctrl-C, ctrl-D, and ctrl-\ with grace:
ctrl-C
displays a new prompt on a new line.ctrl-D
exits the shell.ctrl-\
does nothing.
Minihell will also support several built-in commands, including:
-
echo (with -n option)
-
cd (change directory)
-
pwd (print working directory)
-
export (set environment variables)
-
unset (unset environment variables)
-
env (print environment)
-
exit (close the shell)
Once you’ve perfected the essentials, you can take on these bonus tasks (not present in this project):
-
Logical Operators: Implement
&&
and||
for command chaining, with support for parentheses to dictate priority. -
Wildcards: Allow
*
to match files in the current directory, adding a bit of flair to your command execution.
-
Ensure you’re working in a Unix-like environment.
-
Install the necessary libraries and headers for readline.
You can git clone the repository by using https protocol
git clone https://github.com/Nihilantropy/Minishell.git
then you can access the directory and run the make command
cd Minishell && make
Fire up your this bad boy:
./minishell
From here you can have some fun, testing basic commands, input and output redirections, builtin commands and pipelines 😄!
Now that you know how it works it's time to buil your own hell... ehm I mean shell 👀!
While testing is not mandatory, it’s highly encouraged! Creating tests will help you understand how your shell behaves in various scenarios and is incredibly helpful during peer evaluations.
When you’re done crafting your Minihell, submit your work to your assigned Git repository. Double-check everything because only what’s in your repo will be graded!
If you are just a C programmer enthusiast... Great job! Upload it to your GitHub and see if you can get any reviews!
After submission, you’ll participate in peer evaluations. This is your chance to see how your peers approached the same challenge and to show off your own work. The more thorough and fair you are in these evaluations, the better the feedback you’ll receive.
Congratulations on embarking on this shell-building adventure! We hope you enjoy every bit of it and walk away with a deeper understanding of how shells work under the hood.
May your code be bug-free and your shell flawless!
Happy hacking! 🎉
If you'd like to see an in-depth analisy of this code, leave a star to let us know! 💌