How ahunter954/42sh works
42sh is a small command-line shell. Its main workflow selects stdin, a script file, or -c input; parses commands into an AST; executes that tree; and frees it before reading the next command. The sampled code supports command lists, if/then/else, pipelines, output redirection, and the true/false builtins. The graph follows visible calls; the README provides no additional capability detail, and unsampled modules are not inferred.
Main entry points: main.c Shell loop · parser.c Parsing · exec.c AST execution · ast.h AST model
Components 10
Shell interface
- Shell loop
src/main.c - Legacy interface
src/42sh.h
Language processing
- Tokenization
src/lexer.c - Parsing
src/parser.c - AST model
src/ast.h - AST construction and cleanup
src/ast.c
Execution runtime
- AST execution
src/exec.c
Other components
- Shell user
- External commands
- Output files
Connections 11
- Shell user → Shell loop: provides input
src/main.c - Shell loop → Parsing: parses input
src/main.c - Parsing → Tokenization: requests tokens
src/parser.c - Parsing → AST construction and cleanup: builds nodes
src/parser.c - Parsing → AST model: uses node types
src/parser.c - Shell loop → AST execution: executes tree
src/main.c - Shell loop → AST construction and cleanup: frees tree
src/main.c - AST execution → AST model: dispatches node types
src/exec.c - AST execution → External commands: runs commands
src/exec.c - AST execution → Output files: writes redirected output
src/exec.c - Shell loop → Legacy interface: includes interface
src/main.c