A compact, modular, POSIX-like shell implemented in C, featuring tokenization, parsing, expansion, execution, builtins, and inter-process communication (pipes/redirections), with support for heredoc and signal handling.
- Modular codebase: lexer, parser/AST, expander, executor, builtins, heredoc, signals, pipex, etc.
- GNU Readline integration: interactive input, history, and line-editing.
- Full pipeline support: multi-process pipelines handled by executor/pipex.
- Redirections & heredoc: robust support for input/output redirection.
- Built-ins: cd, echo, pwd, export, unset, env, exit, etc.
- Reusable helpers: bundled
libftfor utilities and reduced dependencies. - Build automation: Makefile with standard targets.
- Active development: frequent commits and improvements.
- Unix-like environment (Linux / macOS)
- C compiler (gcc / clang)
- GNU Readline development headers/libraries installed (for readline/history)
- Make
On Debian/Ubuntu you can install the readline development package with:
sudo apt-get install libreadline-devFrom the repository root:
makeThis will compile the project using the provided Makefile. Typical targets in this Makefile include building the executable (minishell) and cleaning object files (make clean, make fclean), though consult the Makefile for exact targets and behaviors.
Start the shell:
./minishellOnce started, you can execute standard system commands, use pipelines and redirections, and run built-in commands.
Example usage:
-
Run a single command
ls -la /tmp
-
Pipelines
cat file.txt | grep hello | wc -l
-
Redirection
echo "hello" > out.txt wc -c < out.txt
-
Heredoc (example)
cat << EOF
line 1
line 2
EOFBuiltins
cd,echo,pwd,export,unset,env,exit
(Exact builtin behavior is implemented in the builtins/ and exec_builtin/ directories. See those files for specific semantics and edge cases.)
- Use the shell interactively to test common flows: pipelines, redirections, heredoc, environment variable expansion, and builtin commands.
- To debug, compile with debugging symbols (edit the Makefile or add
CFLAGS=-g) and run under gdb or use valgrind to check for memory issues:
make CFLAGS=-g
gdb ./minishell
valgrind --leak-check=full ./minishell