A tiny Unix shell written in C as a side project.
The goal is to build a shell from scratch and learn how processes, file descriptors, input handling, pipes, redirection, and system calls work.
make ./minish./minish- Interactive and non-interactive modes
- Command-line input using
getline() isatty()detectionexitand EOF handling
- Execute external programs
- Command arguments
- Process creation with
fork() - Program execution with
execvp() - Parent synchronization with
waitpid()
Examples:
minish$ ls
minish$ ls -la
minish$ echo hello
minish$ pwdcd— change working directoryenv— display environment variablesexit— exit the shell
Built-ins are handled directly by Minish rather than executed as separate processes.
<— redirect standard input>— redirect standard output>>— append standard output- File handling with
open() - File descriptor replacement with
dup2()
Examples:
minish$ cat < file.txt
minish$ echo hello > file.txt
minish$ echo world >> file.txt- Unix pipes using
pipe() - Multiple commands connected with
| - Process communication through file descriptors
- Pipeline synchronization with
waitpid()
Example:
minish$ ls | grep .c
minish$ ls | wc -lSIGINThandling forCtrl-CSIGQUIThandling- Separate signal behavior for the shell and child processes
- Signal configuration using
sigaction()
- Dedicated command parser
- Separation of parsing and execution
- Quoted arguments
- Environment variable expansion
- Unmatched quote detection
Examples:
minish$ echo "hello world"
minish$ echo 'hello world'
minish$ echo $HOME
minish$ echo $USERminish/
├── include/
│ └── minish.h
├── src/
│ ├── main.c
│ ├── input.c
│ ├── executor.c
│ ├── builtins.c
│ ├── pipes.c
│ ├── signals.c
│ └── parser.c
├── Makefile
├── .gitignore
├── LICENSE
└── README.md
makeTo perform a clean rebuild: make re
./minishmake cleanRemove all build files and the executable: make fclean
Minish is intentionally developed incrementally. Advanced shell features such as:
- More complete quoting rules
- Complex command parsing
- Advanced redirection
- Command history
- Job control
- Shell scripting features
- Wildcard expansion
are not yet implemented.
MIT License