Minishell is a compact partly POSIX compatibly shell supporting the most basic commands and functionalities.
Minishell is able to execute binaries, read from files, redirect output as well as navigating the file system.
In embedded systems, understanding how an Operating System manages processes and communication is vital. Minishell demonstrates our expertise in:
-
Process Management: Utilizing fork, execve, and waitpid to manage lifecycle and execution.
-
Inter-Process Communication (IPC): Implementing pipes (|) to redirect data flow between decoupled processes.
-
Signal Handling: Managing asynchronous events like Ctrl-C, Ctrl-D, and Ctrl-\ to ensure system stability.
-
File Descriptor Manipulation: Handling redirections (>, <, >>, <<) by manipulating system-level file descriptors.
1. Command Execution & Path Finding
The shell searches for executables in the PATH environment variable, handles absolute and relative paths, and executes them with proper argument vectors.
2. Built-in Commands
We implemented several essential shell built-ins from scratch:
echo(with -n option)cd(with relative and absolute paths)envexitexportpwdunset
3. Operators
><>><<|
3. Syntax Parsing & Lexing
The project includes a custom-built lexer and parser to handle:
-
Quoting: Correctly interpreting single (') and double (") quotes, including environment variable expansion inside double quotes.
-
Redirections: Directing output and input to/from files.
-
Pipes: Enabling complex command chains where the output of one command becomes the input of the next.
As a shell is a long-running process, memory management is critical. We utilized Valgrind throughout development to ensure that all allocated memory is properly freed upon command completion or shell exit, and that no file descriptors are left "leaking" open.
Minishell is dependent on GNU readline library.
git clone https://github.com/Sirelaw/minishell.git
cd minishell
make
./minishell