Shellify is a simple, lightweight shell implementation written in C. It provides core shell functionality with a clean, straightforward interface.
Shellify currently supports:
- Basic command execution
- Command-line argument parsing with support for spaces and special characters
- Built-in commands:
cd- Change directory (with support for empty argument to navigate to HOME)pwd- Print working directorypath- Set search paths for executable discoveryexit- Exit the shell
- I/O redirection with
>operator - Command piping with
|operator (multiple pipes supported) - Path search for executable programs
- Signal handling
- Quoted argument handling (both single and double quotes)
- Process group management for proper job control
To build and install Shellify:
git clone https://github.com/AhmedSobhy01/shellify.git
cd shellify
makeAfter building, run the shell:
./shellifyshellify> ls -l # Run a command with arguments
shellify> cd /path/to/dir # Change directory
shellify> cd # Change to HOME directory
shellify> pwd # Show current directory
shellify> ls -la > output.txt # Redirect output to a file
shellify> exit # Exit the shellshellify> ls -l | grep ".txt" # Pipe ls output to grep
shellify> cat file.txt | sort | uniq # Chain multiple pipes
shellify> ps aux | grep bash | wc -l # Count bash processes
shellify> find . -type f | grep "\.c$" > src.txt # Combine pipes with redirectionSet directories where Shellify should look for executables:
shellify> path /bin /usr/bin /usr/local/binUsing no arguments clears the path:
shellify> pathShellify supports quoted arguments for handling spaces and special characters:
shellify> echo "Hello World" # Double quotes
shellify> touch "my file.txt" # Spaces in filenames
shellify> echo 'Single quoted string' # Single quotes
shellify> grep "search term" "file with spaces.txt"Quotes also support multi-token arguments:
shellify> echo "This is all one argument despite the spaces"Shellify is structured into several modules:
- shellify.c/h: Main shell logic, command processing, signal handling, and pipeline execution
- commands.c/h: Built-in command implementations and path resolution
- utils.c/h: Utility functions for argument parsing and command handling
The shell follows a modular design:
- Input Processing: Command-line input is read and parsed into arguments
- Command Execution:
- Built-in commands are handled internally
- External commands are executed by searching the PATH
- Pipelines create multiple processes with connected I/O
- Signal Handling: Custom handlers manage interrupts and terminal control
- Process Management: Process groups are used for job control
Shellify implements proper signal handling to manage:
- Ctrl+C (SIGINT) for interrupting running commands
- Terminal control signals for managing foreground/background processes
- Process groups to ensure signals are delivered properly
- Command history navigation with the arrow keys
- Support for environment variables
- Input/output redirection for standard error
This project is licensed under the MIT License - see the LICENSE file for details.
