How tenaryo/tsh works
TSH is an interactive POSIX-style shell. Its main workflow reads a command line, tokenizes it, parses commands and pipelines, then executes builtins or external programs with redirection. Other documented capabilities include command history with HISTFILE persistence and tab completion backed by a PATH executable cache. The graph includes these capability branches; some links rely on README documentation because the relevant reader and parser implementations were not excerpted.
Main entry points: execute.cpp Executor · reader.cpp Line reader · executable_cache.cpp Executable cache · parse.cpp Parser
Components 16
Shell Interaction
- Line reader
src/reader.cpp - Readline
Command Language
- Lexer
src/lexer.cpp - Parser
src/parse.cpp - Command model
include/types.hpp
Command Execution
- Executor
src/execute.cpp - Builtin commands
src/commands.cpp - External programs
src/execute.cpp - Pipeline handling
src/execute.cpp - Redirect application
src/execute.cpp - FD redirect RAII
src/redirect.cpp
Interactive Features
- History commands
src/commands.cpp - Tab completion
src/reader.cpp - Executable cache
src/executable_cache.cpp
Other components
- Shell user
- PATH executables
Connections 18
- Shell user → Line reader: enters commands
README.md - Line reader → Readline: reads input
README.md - Line reader → Lexer: passes line
- Lexer → Parser: produces tokens
README.md - Parser → Command model: builds AST
README.md - Parser → Executor: passes pipelines
- Executor → Builtin commands: dispatches builtins
src/execute.cpp - Executor → External programs: forks and executes
src/execute.cpp - Executor → Pipeline handling: runs multi-command
src/execute.cpp - Executor → Redirect application: applies child redirects
src/execute.cpp - Executor → FD redirect RAII: redirects builtin output
src/execute.cpp - Builtin commands → Executable cache: looks up command type
src/commands.cpp - Executor → Executable cache: checks executable
src/execute.cpp - History commands → Readline: uses history API
src/commands.cpp - Line reader → History commands: persists HISTFILE
README.md - Line reader → Tab completion: offers completion
README.md - Tab completion → Executable cache: completes PATH names
README.md - Executable cache → PATH executables: scans PATH
src/executable_cache.cpp