Minishell Explanation
Minishell Explanation
========================================================
OVERVIEW:
---------
Minishell is a simplified version of bash that can execute commands, handle pipes,
redirections,
environment variables, and built-in commands. It provides a command-line interface
where users
can type commands and get results, just like a regular terminal.
MAIN COMPONENTS:
---------------
1. Input Reading and Parsing
2. Tokenization
3. Variable Expansion
4. Command Execution
5. Built-in Commands
6. Redirection and Pipes
7. Signal Handling
8. Environment Management
STEP 4: TOKENIZATION
-------------------
- The preprocessed line goes to get_tokens() function
- Creates a linked list of tokens, where each token contains:
* The string content
* A type (CMD, ARG, PIPE, TRUNC, APPEND, INPUT, END, EMPTY)
* Pointers to previous and next tokens
- Handles quoted strings (both single and double quotes)
- Handles escaped characters with backslashes
- Determines token types based on content and position
ERROR HANDLING:
--------------
- Memory allocation failures
- File access errors for redirections
- Command not found errors
- Permission denied errors
- Syntax errors in input
- Signal interruptions
SPECIAL FEATURES:
----------------
- Maintains command history through session
- Supports complex command chaining with pipes and redirections
- Handles nested quotes and escaped characters
- Manages environment variables properly
- Provides colored prompt with status indication
- Maintains shell level tracking (SHLVL)