A custom shell implementation in C that supports command execution, job control, piping, and persistent command history. It features a custom parser and state management system for interactive terminal use.
- Directory Navigation (
hop): Replacement forcd. Supports absolute/relative paths,~,.,.., and-(previous directory). Multiple arguments are processed sequentially. - Directory Listing (
reveal): Replacement forls. Supports-l(long format) and-a(show hidden files). - Persistent History (
log): Latest 15 commands are stored inlogs.txt. View, purge, or re-execute commands by index. Commands starting withlogare not logged to prevent recursion. - Job Control:
- Background Execution: Use
&to run commands in the background. - activities: Lists running/stopped background jobs.
- fg / bg: Bring jobs to foreground or resume in background.
- ping: Send signals to processes by PID. Signal number is mapped as
signal_num % 32.
- Background Execution: Use
- System Interactions:
- Piping (
|): Chain commands, passing output as input. - I/O Redirection: Supports
<,>, and>>. - Signal Handling: Handles
Ctrl+C(SIGINT) to terminate foreground processes andCtrl+D(EOF) to exit.
- Piping (
make # Compile the shell
./shell.out # Run the shell
make run # Compile and run
make clean # Remove build artifacts- Command Names: Uses
hop,reveal,log, andactivitiesinstead ofcd,ls,history, andjobs. - Signal Mapping:
pingapplies modulo 32 to signal numbers. - Job Limit: Maximum 100 background jobs.
- Termination Notifications: Background job completion is reported at the next prompt, not immediately.
- Job Selection Logic: When
fgorbgis run without a job ID, the shell selects the oldest active job available. - Parsing Redirection Symbols: Redirection operators (
<,>,>>) must be preceded by a space; otherwise, the syntax is considered invalid. - Multiple Output Redirections: When multiple output redirections are present (e.g.,
command > file1 > file2), only the last one takes effect; all previous output redirections are ignored. - Sequential hop: If multiple arguments are provided to
hopcommand, it sequentially processes them and stops once at the end or it encounters any invalid directory name.
Makefile
LICENSE
README.md
include/
*.h # Header files for modules
src/
*.c # Source files for modules
hop: Directory navigationreveal: Directory listinglog: Command historyactivities: Job managementping: Signal sendingprompt,command,parser,shell_state,signal_handle: Core shell logic
- Designed for educational purposes and experimentation.
- Not POSIX-compliant; intended as a learning project.