Skip to content

Shellify is a simple, lightweight shell implementation written in C, it provides core shell functionality with a clean, straightforward interface

License

Notifications You must be signed in to change notification settings

AhmedSobhy01/shellify

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Shellify

Shellify Logo

Shellify is a simple, lightweight shell implementation written in C. It provides core shell functionality with a clean, straightforward interface.

✨ Features

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 directory
    • path - Set search paths for executable discovery
    • exit - 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

📥 Installation

To build and install Shellify:

git clone https://github.com/AhmedSobhy01/shellify.git
cd shellify
make

🚀 Usage

After building, run the shell:

./shellify

💻 Basic Commands

shellify> 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 shell

🔄 Command Piping

shellify> 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 redirection

🛣️ Path Management

Set directories where Shellify should look for executables:

shellify> path /bin /usr/bin /usr/local/bin

Using no arguments clears the path:

shellify> path

💬 Quoted Arguments

Shellify 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"

🔧 Implementation Details

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

Architecture

The shell follows a modular design:

  1. Input Processing: Command-line input is read and parsed into arguments
  2. Command Execution:
    • Built-in commands are handled internally
    • External commands are executed by searching the PATH
    • Pipelines create multiple processes with connected I/O
  3. Signal Handling: Custom handlers manage interrupts and terminal control
  4. Process Management: Process groups are used for job control

Signal Handling

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

🔮 Future Plans

  • Command history navigation with the arrow keys
  • Support for environment variables
  • Input/output redirection for standard error

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

About

Shellify is a simple, lightweight shell implementation written in C, it provides core shell functionality with a clean, straightforward interface

Topics

Resources

License

Stars

Watchers

Forks