- Add control_flow.rs module with execution for if/while/for/case statements
- Add Statement::Script variant for multi-line scripts
- Fix grammar to reserve keywords (if, then, fi, while, do, done, for, in, case, esac)
- Fix bare_word_part to exclude semicolons
- Make NEWLINE silent to prevent parse tree pollution
- Update command_line grammar to support multiple commands
- Add keyword_boundary rule for proper keyword matching
- Update CLI to handle Statement::Script and execute all control flow types
- Add parser tests for if statements and multiline scripts
If statements are fully working. While/for/case loops need additional testing and fixes.
- Update execute_line to handle Statement::Complete(CompleteCommand)
- Add execute_complete_command dispatcher for all command types
- Maintain existing Simple and Pipeline execution
- Add TODO placeholders for control flow execution:
- AndOrList (&&, ||)
- If statements
- While loops
- For loops
- Case statements
- Shell remains functional with existing features
Parser implementation:
- Rewrite parse_command_line to handle complete_command
- Add parse_complete_command dispatcher for all statement types
- Add parse_and_or_list for && and || operators
- Add parse_if_statement with elif_clause and else_clause support
- Add parse_while_statement for while loops
- Add parse_for_statement for for-in loops
- Add parse_case_statement with case_clause pattern matching
- Add parse_command_list for command sequences
- Update parse_pipeline to return Pipeline directly
- Update all 15 existing tests to use Statement::Complete(CompleteCommand)
- All tests passing
Library exports:
- Export all new AST types: CompleteCommand, AndOrList, AndOrOp, IfStatement,
ElifClause, WhileStatement, ForStatement, CaseStatement, CaseClause, Pipeline, Redirect
- Simplify execute_line() to use new executor functions
- Use execute_simple_with_redirects() for simple commands
- Use execute_pipeline() for multi-command pipelines
- Handle Statement::Pipeline variant
- Remove manual assignment processing (now in executor)
- Maintain proper exit status tracking for both command types
- Add redirect.rs module for handling all I/O redirections
- Implement apply_redirects() to configure Command stdio
- Support input (<), output (>), append (>>), stderr (2>), and combined (&>) redirects
- Proper file expansion and error handling
- Add pipeline.rs module for executing command pipelines
- Create pipes between commands using Stdio::piped()
- Chain stdout of each command to stdin of next
- Wait for all processes and return last exit status
- Implement execute_simple_with_redirects() for unified command execution
- Update command.rs to expose helper functions
- Make find_in_path, execute_builtin, success_result public(crate)
- Add rush-expand dependency to rush-executor
- add Context to all execution modes
- update execute_line to handle assignments and expansion
- process variable assignments before command
- expand all words (variables, command substitution)
- track exit status in context
- persist Context across commands in REPL
- maintain separate Context per execution mode
Working features:
- variable assignment: FOO=bar
- variable expansion: $FOO, ${FOO}
- command substitution: $(pwd)
- quoted strings with expansion: "Hello $NAME"
- assignments persist across commands in same session
- add execute_command_substitution() function
- execute commands via sh -c (for now)
- trim trailing newlines (bash behavior)
- integrate with expand_word()
- add tests for command substitution
- 16 tests passing total
- move Context from rush-eval to rush-expand (avoid circular deps)
- implement expand_word() for all expansion types:
- literal text
- variable expansion ($VAR, ${VAR})
- default values (${VAR:-default})
- implement expand_words() for multiple words
- add Context for variable storage:
- local and exported variables
- environment variable initialization
- exit status tracking
- 10 passing tests for expansion and context
- extend Pest grammar for variable syntax
- variable assignments: VAR=value
- variable expansion: $VAR, ${VAR}, ${VAR:-default}
- command substitution: $(cmd)
- double-quoted strings with expansions
- update AST to support:
- Assignment type
- Word composed of multiple WordParts
- VarExpansion types (Simple, Braced, WithDefault)
- CommandSubstitution
- rewrite parser for new grammar
- explicit whitespace handling to prevent word merging
- proper separation of assignments and words
- add comprehensive tests for new features
- implement process group management for child processes
- add signal handling (SIGINT, SIGTSTP, SIGTTOU)
- give foreground processes terminal control
- properly wait for child processes with WUNTRACED
- handle stopped processes (Ctrl+Z)
- restore terminal control to shell after command