How tresor850/minshell2--42sh works
This repository implements a small interactive Unix shell: it reads command lines, dispatches commands, supports built-ins and environment changes, and executes external programs with redirection and pipeline support. The main loop and command dispatcher are visible in excerpts; some domain-stage implementations are indexed but not sampled, so uncertain dispatch links are omitted or marked unverified.
Main entry points: process_command.c Single command · execution.c External execution · handle_command.c Command dispatcher · main.c Input loop
Components 16
Shell input
- Input loop
src/main.c
Command handling
- Command dispatcher
src/handle_command.c - Semicolon splitting
src/semicolon.c - Single command
src/process_command.c - Built-ins
src/handle_command.c - Command tokenization
src/my_str_to_word_array.c - Pipe splitting
src/mys_str_to_word_array.c
Execution and state
- Directory changes
src/change_directory.c - Environment list
src/set_env.c - Environment conversion
src/list_to_tab.c - Command lookup
src/find_command.c - Executable path check
src/parser.c - External execution
src/execution.c - I/O redirection
src/redirections.c - Pipeline execution
src/pipe.c
Other components
- Shell user
Connections 16
- Shell user → Input loop: enters commands
src/main.c - Input loop → Command dispatcher: submits line
src/main.c - Command dispatcher → Semicolon splitting: splits commands
src/handle_command.c - Command dispatcher → Single command: processes each
src/handle_command.c - Built-ins → Directory changes: changes directory
src/handle_command.c - Built-ins → Environment list: updates variables
src/handle_command.c - Command dispatcher → Environment conversion: serializes environment
src/handle_command.c - External execution → Command lookup: finds executable
src/execution.c - External execution → I/O redirection: applies redirection
src/execution.c - External execution → Command tokenization: tokenizes input
src/execution.c - Command lookup → Executable path check: checks candidate paths
- Single command → Built-ins: dispatches built-ins
- Single command → External execution: runs external command
- Single command → Pipe splitting: splits pipeline
- Single command → Pipeline execution: runs pipeline
- Pipeline execution → External execution: executes stages
src/pipe.c