Commit 0c411f8
feat: implement quote processing (Phase 6 M13)
Milestone 13 complete: POSIX-compliant quote processing with
quote-aware glob expansion integration.
## New Module
- src/quotes.rs (~600 lines):
- QuoteState enum: Unquoted, SingleQuoted, DoubleQuoted
- QuotedSegment struct: text + quote state pairing
- parse_quotes(): Full POSIX quote parser
- should_expand_glob(): Quote-aware glob pattern detection
- reconstruct_string(): Segment reconstruction helper
- 17 unit tests (all passing)
## Parser Integration
- Modified src/parser.rs:
- quoted_word_to_string(): Now escapes glob metacharacters (*, ?, [, {)
in quoted contexts (both single and double quotes)
- Escaped patterns prevent glob expansion via contains_glob_pattern()
- Preserves existing variable expansion handling
## POSIX Quote Semantics
- Single quotes ('...'):
- All characters literal, no expansion whatsoever
- Cannot contain single quote (even escaped)
- Whitespace preserved
- Double quotes ("..."):
- Variable expansion: $VAR, ${VAR}
- Command substitution: $(cmd), `cmd`
- Arithmetic expansion: $((expr))
- NO glob expansion (patterns stay literal)
- Backslash escapes: \$, \`, \", \\, \newline
- Backslash (unquoted):
- Escapes next character literally
- Line continuation: backslash-newline removed
## Quote + Glob Integration
- Quoted globs don't expand:
- '*.txt' → stays literal "*.txt"
- "*.txt" → stays literal "*.txt"
- Unquoted globs expand:
- *.txt → file1.txt file2.txt
- Escaped globs don't expand:
- \*.txt → stays literal "*.txt"
## Testing
- All 157 library tests passing (including 17 quote tests)
- Integration verified: escaped glob patterns not detected
- Quote behaviors: whitespace, escaping, line continuation
## State Updates
- STATE.scm:
- Overall completion: 85% → 90%
- Phase: M12 Complete → M13 Complete
- Removed "Quote processing not implemented" blocker
- Added quote processing + quote-aware glob to working-features
- Added session history entry
## Documentation
- docs/PHASE6_M13_DESIGN.md: Complete design document (800+ lines)
Phase 6 progress: 13/14 milestones complete (90%)
Next: M14 Full POSIX shell compliance (final milestone)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>1 parent 6d7f3ec commit 0c411f8
5 files changed
Lines changed: 1486 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
30 | | - | |
| 29 | + | |
| 30 | + | |
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| |||
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
| 76 | + | |
| 77 | + | |
76 | 78 | | |
77 | 79 | | |
78 | 80 | | |
| |||
193 | 195 | | |
194 | 196 | | |
195 | 197 | | |
196 | | - | |
197 | | - | |
| 198 | + | |
198 | 199 | | |
199 | 200 | | |
200 | 201 | | |
| |||
224 | 225 | | |
225 | 226 | | |
226 | 227 | | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
227 | 257 | | |
228 | 258 | | |
229 | 259 | | |
| |||
0 commit comments