GazaShell is a custom shell implementation written in C and C++. It provides a command-line interface for executing commands with support for input/output redirection, pipelines, and conditional execution.
- Command Processing: Tokenizes and parses user input into executable commands
- Pipelines: Connect multiple commands with pipes (
|) - Conditional Execution: Support for
&&and||operators - Sequential Execution: Execute commands in sequence with
; - Parallel Commands: Run commands in Parallel using
& - I/O Redirection: Handle input (
<), output (>), and error (2>) redirection - Built-in Commands: Includes essential commands like
cd,pwd,path, andexit
.
├── src/
│ ├── builtin.c # Built-in command implementations
│ ├── command.c # Command execution logic
│ ├── conditional_cmd.c # Conditional command handling
│ ├── list.c # List data structure implementation
│ ├── parser.c # Command parsing module
│ ├── path.c # Path management
│ ├── pipe.c # Pipeline implementation
│ ├── scanner.c # Input tokenization
│ ├── include/ # Header files
│ ├── builtin.h
│ ├── command.h
│ ├── conditional_cmd.h
│ ├── list.h
│ ├── parser.h
│ ├── path.h
│ ├── pipe.h
│ ├── scanner.h
├── v0/
│ ├── GazaShell.cpp # Initial implementation
├── main.c # Main entry point
├── README.md
Tokenizes user input by breaking it down into individual tokens using delimiters like spaces and tabs.
Processes tokens into structured commands, handling operators for redirection, pipelines, and conditional execution.
Manages command execution through system calls, implements I/O redirection, and handles exit statuses.
Native shell functions that don't spawn new processes, including:
cd: Change directorypwd: Print working directorypath: Manage command search pathsexit: Terminate the shell
-
Build the project:
mkdir build cd build cmake .. make -
Run GazaShell:
./wish
wish> ls -l
wish> pwdwish> ls -l | grep ".c" | wc -lwish> ls > files.txt
wish> cat < input.txt
wish> find / -name "*.c" 2> errors.logwish> mkdir test && cd test || echo "Failed to create directory"wish> echo a & echo b & echo c & echo dwish> echo "First command"; echo "Second command"wish> cd /path/to/directory
wish> pwd
wish> exitwish> path /bin /usr/bin /usr/local/binContributions are welcome! Feel free to submit issues or pull requests for bug fixes, enhancements, or new features.
