How jsenk347/homebrew-shell works
homebrew-shell is a small Linux command shell. Its main workflow reads a line, parses it into a job containing pipeline stages and optional redirections/background mode, launches the stages, then waits for foreground children or reaps background ones. The main product branches are parsing, process execution, and signal handling, with a small custom allocation/string layer supporting them. The README documents the shell’s purpose and launch command; the sampled source confirms these runtime features. No additional capabilities are documented.
Main entry points: run_job.c Job runner · mysh.c Shell loop · commands.c Job parser · myheap.c Heap allocator
Components 18
Shell interaction
- Shell loop
mysh.c - Line input
commands.c - Signal control
mysh.c
Command parsing
- Job model
jobs.h - Job parser
commands.c
Job execution
- Job runner
run_job.c - Redirection I/O
run_job.c - Pipe setup
run_job.c - Stage I/O
run_job.c - Child launcher
commands.c - Command path
commands.c - Foreground wait
run_job.c
Runtime support
- Heap allocator
myheap.c - String helpers
mystring.c
Other components
- Shell user
- External programs
- Linux process services
- Redirection files
Connections 22
- Shell user → Line input: enters commands
- Shell loop → Line input: reads line
- Shell loop → Job parser: parses job
- Job parser → Job model: fills job
- Job parser → Heap allocator: allocates tokens
- Job parser → String helpers: measures strings
- Shell loop → Job runner: runs job
- Job runner → Redirection I/O: opens files
- Redirection I/O → Redirection files: reads or writes
- Job runner → Pipe setup: creates pipes
- Pipe setup → Linux process services: creates processes
- Job runner → Stage I/O: assigns descriptors
- Job runner → Child launcher: launches stages
- Child launcher → Command path: resolves command
- Child launcher → Linux process services: forks and executes
- Child launcher → External programs: executes program
- Command path → Heap allocator: allocates path
- Job runner → Foreground wait: waits if foreground
- Foreground wait → Linux process services: waits for children
- Shell loop → Signal control: sets handlers
- Signal control → Linux process services: handles signals
- Linux process services → Signal control: dispatches SIGCHLD