SAFSH is a minimalistic Unix-like command-line shell written in C, built for fun, experimentation, and learning how shells work under the hood.
- Prompt displays the current directory name
- Supports execution of external commands via
execvp - Basic built-in commands:
cd— Change the current working directoryhelp— Display help message for built-in commandsexit— Exit the shell
- Command line editing and history support via GNU Readline
- Handles
SIGINT(Ctrl+C) gracefully - Dynamic memory management for token parsing
- Uses
forkandwaitpidto manage child processes
- GCC (or any modern C compiler)
- GNU Readline development headers (e.g.,
libreadline-devon Debian/Ubuntu)
makeIf make throws unused-variable warnings, the code is still functional. You can alternatively compile manually:
gcc safsh.c -o safsh -lreadline./safshOnce running, you'll see the shell prompt display like:
foldername =>You can enter any valid system command or one of the built-in commands.
~/Documents => cd ..
~/ => ls
Documents Downloads safsh
~/ => exit
Exiting SAFSH....
├── safsh.c # Main shell source code
├── Makefile # Build instructions
└── README.md # Project description
- Add support for command piping (
|) - Implement input/output redirection (
<,>) - Add support for environment variables
- Tab completion (via readline)
- Script file execution
This project is provided for educational purposes under the MIT License.
Created by selfAnnihilator