Minishell - BASH Inspired Shell

AST
Low Level
Shell
GitHub
minishell screenshot

Minishell is a lightweight shell implementation inspired by BASH, developed as part of my studies at 42 School. While I had used shells daily, working on Minishell gave me a deep understanding of how they operate under the hood. The project covers parsing, executing commands, handling pipes and redirections, and interacting with the operating system through system calls. Some advanced features, such as job control, are not yet implemented and remain opportunities for future development.

Technologies

Minishell had to be done in C language, and only a dozen functions of the standard library were allowed (mainly system calls), everything else I had to implement myself.

Features

Like any shell, it takes a command as a string, which must be parsed and then executed. This seemingly simple workflow is surprisingly complex: a command can contain multiple subcommands (subprocesses), be piped to other commands, its input/output redirected to a file, and/or executed conditionally based on other commands’ results.

Challenges

One of the main challenges was parsing the command input. I began by tokenizing the input string—converting it from raw bytes into recognized shell symbols. Because the project was written in C, even basic string manipulation functions like splitting or joining strings had to be implemented from scratch. Any small mistake in these building blocks could break the entire parsing logic. Once tokenized, the input was transformed into an Abstract Syntax Tree (AST)—assigning structure and meaning to tokens according to shell grammar. Building this tree was one of the most challenging parts, as it required designing recursive algorithms and understanding syntax parsing from the ground up.

Key Learning

Through this project, I was able to deepen my understanding of parsing, system calls, state machines, recursion, binary tree construction and traversal, and more importantly rigorous error handling and memory management—since any memory leak/bug resulted in project rejection.