100 lines
4.7 KiB
HTML
100 lines
4.7 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<title></title>
|
|
<link href="/css/style.css" rel="stylesheet">
|
|
</head>
|
|
<body>
|
|
<header>
|
|
<h1>Minishell - The Shell</h1>
|
|
<nav>
|
|
<a href="/en">Home</a>
|
|
<a href="mailto:victor@victorvobis.org">Email</a>
|
|
<a href="https://git.victorvobis.org/victorvobis" target="_blank">Git</a>
|
|
<a href="https://git.victorvobis.org/victorvobis/minishell" target="_blank">Source</a>
|
|
<a href="/de">Deutsch</a>
|
|
</nav>
|
|
</header>
|
|
<main>
|
|
<section class="content">
|
|
<h2>The Shell</h2>
|
|
<p style="font-weight: bold;">
|
|
Bash-like Shell. From Scratch. In C. <a href="#demo">Demo Below</a>
|
|
</p>
|
|
<div class="space-y-2">
|
|
<p>
|
|
The minishell project is part of the common core curriculum at
|
|
<a class="underline text-blue-700 hover:text-blue-900" href="https://42vienna.com">42Vienna</a> and
|
|
is seen as a milestone and one of the biggest jumps in complexity on the way to completing the cursus.
|
|
</p>
|
|
<p>
|
|
The rules are simple: Create a program that will replicate basic shell behaviour like typically found on POSIX systems.
|
|
</p>
|
|
<p>
|
|
Some of the requirements are:
|
|
</p>
|
|
<ul>
|
|
<li>Custom <a href="https://github.com/gnu-mirror-unofficial/readline">readline</a> function</li>
|
|
<li>Command line parsing</li>
|
|
<li>I/O loop to accept continuous commands</li>
|
|
<li>Command execution</li>
|
|
<li>File Descriptor redirection</li>
|
|
<li>Pipe Operators</li>
|
|
<li>Environment Variables</li>
|
|
<li>Builtin functions (cd, export, exit etc.)</li>
|
|
<li>Heredoc</li>
|
|
<li>Logical AND ( && )</li>
|
|
<li>Logical OR ( || )</li>
|
|
<li>and more...</li>
|
|
</ul>
|
|
<p>
|
|
The program has to be written in C, we are working on GNU/Linux machines.
|
|
</p>
|
|
<p>
|
|
We are also required to follow a very strict norm on which you can read more
|
|
<a href="/assets/42-norm.pdf">here</a>.
|
|
</p>
|
|
<p>
|
|
What makes the 42 projects stand out in my opinion is that the tools we use are very restricted — essentially only
|
|
syscalls to interface with the kernel, some utility functions and memory functions, and in this case we were allowed to use
|
|
printf, which is normally forbidden.
|
|
This means that all utility has to be implemented by hand, and all relevant code will be written by the project's authors.
|
|
</p>
|
|
<p>
|
|
We were allowed to use the readline function used in bash to handle user input.
|
|
Since memory leaks of any kind are considered an unrecoverable mistake when validating a project, and the readline function would
|
|
inevitably leak memory, those leaks were explicitly tolerated by the project's requirements.
|
|
</p>
|
|
<p>
|
|
But, out of curiosity, I decided to recreate the readline function, removing the dependency and leaks from our project,
|
|
and learning a lot along the way.
|
|
In my opinion, this is one of the more interesting parts of our implementation, and I very much enjoyed it!
|
|
</p>
|
|
<p>
|
|
This project was a team effort, and big thanks go out to my team partner and good friend,<br/>
|
|
<a href="https://github.com/zekmaro">Andrej Arama</a>!
|
|
</p>
|
|
|
|
<p>
|
|
The source code for the project can be seen on my
|
|
<a href="https://git.victorvobis.org/victorvobis/minishell">git server</a> and
|
|
I have also provided a live version of the shell below.<br/>
|
|
</p>
|
|
<p>
|
|
Many thanks to
|
|
<a href="https://github.com/tsl0922/ttyd">ttyd</a>
|
|
for the web integration!<br/>
|
|
Have fun!
|
|
</p>
|
|
<h2 id="demo">Demo</h2>
|
|
<div id="shell-container" style="height: 400px;">
|
|
<iframe sandbox="allow-same-origin allow-scripts" src="/proxy/minishell/" style="width: 100%; height: 100%; border: none; display: block;"></iframe>
|
|
</div>
|
|
</div>
|
|
</section>
|
|
</main>
|
|
</body>
|
|
</html>
|