How r4yl-dev/minishell works
MiniShell is an interactive Bash-like shell. Its main loop initializes shell state, reads a prompt, then lexes, parses, expands, and executes each nonempty command; EOF exits. Execution handles external programs, builtins, pipes, and redirections, while signal handling and shell variables support the session. The README documents the user-visible stages and capabilities; sampled source confirms the main-loop dispatch, parser tree construction, and execution behavior. Other subsystem links below reflect documented workflow, not inspection of unsampled implementations.
Main entry points: main.c Shell loop · exec_env.c Command dispatch · exec.c Executor · prompt.c Prompt input
Components 19
Interactive session
- Prompt input
prompt/prompt.c - Shell loop
main.c - Signal handling
signals/handle_sigint.c
Command processing
- Lexer
lexer/lexer.c - Token list
lexer/dyntklist.c - Parser
parser/parser.c - Command tree
parser/dyntree.c - Expansion
expand/expand.c
Execution runtime
- Executor
exec/exec.c - Command dispatch
exec/exec_env.c - Executable lookup
exec/get_cmd_path.c - Pipes and redirects
exec/get_infd.c - Here-doc input
exec/make_heredoc.c - Builtin commands
builtins/lstbuiltins_exec.c
Shell state
- Shell variables
vars/grpvar.c - Shell context
ctx/ctx.c - Process environment
exec/make_env.c
Other components
- Shell user
- Terminal and files
Connections 21
- Shell user → Prompt input: enters commands
- Shell loop → Prompt input: reads input
main.c - Prompt input → Shell loop: returns line
- Shell loop → Signal handling: sets signal mode
main.c - Shell loop → Lexer: lexes input
main.c - Lexer → Token list: builds tokens
- Shell loop → Parser: parses tokens
main.c - Parser → Command tree: builds tree
parser/parser.c - Shell loop → Expansion: expands command
main.c - Shell loop → Executor: executes tree
main.c - Executor → Command dispatch: dispatches work
- Command dispatch → Executable lookup: resolves programs
- Command dispatch → Builtin commands: runs builtins
exec/exec_env.c - Executor → Pipes and redirects: configures I/O
- Executor → Here-doc input: collects here-docs
- Builtin commands → Shell variables: updates variables
- Shell loop → Shell context: initializes context
main.c - Shell context → Shell variables: holds shell state
- Command dispatch → Process environment: builds process env
exec/exec_env.c - Prompt input → Terminal and files: reads terminal
- Command dispatch → Terminal and files: runs programs and I/O