smallsh is a simple Unix-like shell written in C. It provides a
subset of features found in popular shells like bash, including
process management, I/O redirection, and custom signal handling.
This project was designed as a hands-on exercise in systems programming, focusing on process control, signals, and command execution using low-level system calls.
📝 Note: This shell was created and tested on a remote Linux server using the Kitty terminal. Some functionalities (especially signal handling or background processes) may not behave exactly the same in other environments or terminal emulators.
- Command Prompt -- Interactive prompt for entering commands\
- Comments & Blank Lines -- Handles blank lines and ignores
#comments\ - Variable Expansion -- Supports
$$expansion, replaced with the shell's process ID
exit-- Exit the shell\cd-- Change current directory\status-- Display exit status of the last foreground process
- Executes external commands via the
execfamily of functions\ - Supports input (
<) and output (>) redirection\ - Run processes in foreground or background using
&
- Foreground/background process management\
- Custom handling for:
SIGINT(Ctrl+C)\SIGTSTP(Ctrl+Z)
- GCC or any C compiler
# Clone repository
git clone https://github.com/weemsj/small_shell.git
# Enter project directory
cd smallsh
# Compile the program
gcc -o smallsh smallsh.c./smallsh# Run in foreground
ls -l
# Run in background
sleep 10 &
# Redirect output
ls > output.txt
# Redirect input
sort < input.txt- Press Ctrl+C to send
SIGINT\ - Press Ctrl+Z to toggle foreground-only mode with
SIGTSTP
Contributions are welcome! Fork this repo, make improvements, and open a PR.
This project is licensed under the MIT License -- see the LICENSE file for details.