MandoSHell is a minimalist command-line interpreter developed in C. The project implements a robust REPL (Read-Eval-Print Loop) to handle user input, argument parsing, and process execution logic.
The system is organized into three distinct logical layers to ensure modularity and maintainability:
- Main Loop (REPL): Manages the primary execution flow, standard input/output, and the dynamic user prompt.
- Parser: Handles string tokenization, transforming the raw input buffer into a null-terminated argument array (
argv). - Dispatcher: Analyzes the initial token to route execution either to an internal builtin function or to an external system binary.
- Dynamic Prompting: Real-time working directory display with automatic HOME directory contraction using the tilde (
~) character. - Exit Status Tracking: Monitoring and storage of the return code from the most recent command (
last_status), adhering to POSIX standards. - Core Builtins: Native implementation of essential commands including
cd,exit,echo, andtype. - Path Resolution: Integration with system environment variables to locate and launch external binaries.
- Error Handling: Systematic reporting of execution failures, including standard exit codes (e.g., 127 for command not found).
2026-03-01.13-12-54.mp4
- GCC or Clang compiler
- CMake (version 3.10 or higher)
This project utilizes CMake for build management. To compile the shell, execute the following commands from the project root:
mkdir build
cd build
cmake ..
makeOnce compiled, the executable can be launched from the build directory: Bash
./msh-
Signal Handling: Manages EOF (End Of File) for graceful session termination.
-
Memory Management: Implements strict memory cleanup after each parsing cycle to prevent leaks during long-running sessions.
-
Process Control: Uses fork, exec, and waitpid logic to manage external process lifecycles and accurately capture exit statuses via system macros.
I wanted to experience some real system programming, I saw this excercise online and I decided to make it from scratc in C. And also because I dont know what I am doing with my life. lol.