How pkhienko/minishell works
Minishell is an interactive Unix shell: it reads a line, tokenizes and validates shell syntax, expands variables, builds piped command records, then executes built-ins or external programs with redirection and exit-status handling. The README also documents prompt history, environment mutation, heredocs, and signal handling. The main loop and executor excerpts establish the central calls; broader feature links use README evidence because their implementation files were not sampled.
Main entry points: main.c Shell loop · execution.c Executor · built_cmd.c Command builder · libft.h C utility library
Components 18
Interactive shell
- Readline
- Shell loop
sources/shell/main.c - Prompt
sources/shell/prompt.c - Signal handling
sources/signal/signal.c
Input processing
- Lexer and parser
sources/lexer - Command builder
sources/init/built_cmd.c - Command records
include/command.h
Command execution
- Executor
sources/executor/execution.c - Pipes and redirects
sources/io_file/io_file.c - Heredoc input
sources/executor/heredoc.c - Built-in commands
sources/builtins - External programs
- Command errors
sources/error
Shell state
- Environment
sources/env - C utility library
libft/include/libft.h - Formatted output
libft/src/printf/ft_printf.c - Line reader
libft/src/get_next_line/get_next_line.c
Other components
- Shell user
Connections 18
- Shell user → Readline: enters input
- Readline → Shell loop: provides lines
- Shell loop → Prompt: gets prompt
sources/shell/main.c - Shell loop → Lexer and parser: tokenizes input
sources/shell/main.c - Shell loop → Command builder: builds commands
sources/shell/main.c - Shell loop → Executor: executes commands
sources/shell/main.c - Lexer and parser → Environment: expands variables
- Command builder → Command records: creates records
sources/init/built_cmd.c - Command builder → Pipes and redirects: creates pipe fds
sources/init/built_cmd.c - Executor → Built-in commands: dispatches built-ins
sources/executor/execution.c - Executor → External programs: executes programs
sources/executor/execution.c - Executor → Pipes and redirects: sets and restores
sources/executor/execution.c - Executor → Heredoc input: checks heredoc status
sources/executor/execution.c - Built-in commands → Environment: updates variables
- Shell loop → Signal handling: handles interrupts
- Executor → Command errors: reports failures
sources/executor/execution.c - C utility library → Formatted output: provides implementation
libft/include/libft.h - C utility library → Line reader: provides implementation
libft/include/libft.h