Commit f4643ff
authored
PR 5: cd-attribution + subshell isolation + bash -c recursion (#8)
Completes the SPEC §9 + §10 behaviors deferred from earlier PRs.
Locked interpretations #4 (bash -c overflow → outer
ParsedCommand.IsUnparseable), #5 (only cd/chdir propagate; pushd/popd
parse but don't), and #6 (cd $VAR → synthetic DynamicSkip attribution
arg) now fully materialized.
What's wired:
- Internal/Bash/Parsing/CdAttributionContext.cs (parser-internal,
mutable):
* SubshellStack of monotonic IDs handles sibling subshells cleanly
(depth alone doesn't distinguish (a) && (b))
* SetLiteralAttribution / SetDynamicAttribution
* HasAttribution flag
- BashCommandParser updates:
* Only cd/chdir update attribution context (interp #5)
* Subsequent clauses get synthetic IsCwdAttribution arg:
- Literal cd target → Kind=Literal, IsPath=true, Resolved=<cwd>
- DynamicSkip cd target → Kind=DynamicSkip, IsPath=false,
Raw="<dynamic-cwd>" (interp #6)
* Subshell ( ... ) entry pushes attribution stack, exit pops; clauses
inside get IsSubshell=true; subshell mutations don't leak out
* bash -c / sh -c real recursion (was single-clause framework in PR 3):
inner ParsedCommand surfaced with IsBashCWrapped=true on each clause;
outer bash -c clause consumed (not emitted)
* Recursion depth cap at 5 → outer ParsedCommand.IsUnparseable=true
with reason "bash -c recursion depth exceeded (>5)" (interp #4)
* Outer cd attribution does NOT leak into bash -c inner clauses (v0.1
decision; tracked for v0.1.x revisit)
- BashResolver internal overload Resolve(raw, treatAsPath, options,
workingDirectoryUnknown): lets the propagator force DynamicSkip on
relative-path args under dynamic cd (interp #6) without polluting
the public BashParserOptions surface.
Tests:
- 8 new parser tests: attribution propagation, subshell isolation,
sequential cd, pushd non-propagation, dynamic cd, sibling subshells,
bash -c depth-2 success, bash -c depth-6 overflow.
- CorpusRunnerTests: added IsCwdAttribution field on ExpectedArg.
- 30 new corpus entries (71-100): 10 cd-in-compound + 10 subshell +
10 bash -c. 5 PR 3-4 corpus entries refreshed (25, 28, 34, 35, 52).
- Total: 337/337 passing (was 296 at PR 4 baseline).
SPEC.md updated:
- §9 rule 3 explicit on which CwdVerbs propagate (only cd/chdir);
added "Dynamic-cd attribution" subsection per interp #6
- §10 subshell flattening rephrased; bash -c recursion-limit replaced
with "set ParsedCommand.IsUnparseable=true" per interp #4
Public API surface unchanged. PublicApiSnapshotTests still 18/18 green.1 parent ddce4c7 commit f4643ff
43 files changed
Lines changed: 1908 additions & 105 deletions
File tree
- openspec/changes/v0.1-locked-interpretations
- src/ShellSyntaxTree/Internal
- Bash/Parsing
- Resolving
- tests/ShellSyntaxTree.Tests
- Corpus
- bash
- Parsing
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
114 | 114 | | |
115 | 115 | | |
116 | 116 | | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
131 | 137 | | |
132 | 138 | | |
133 | 139 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
680 | 680 | | |
681 | 681 | | |
682 | 682 | | |
683 | | - | |
684 | | - | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
685 | 692 | | |
686 | 693 | | |
687 | 694 | | |
| |||
693 | 700 | | |
694 | 701 | | |
695 | 702 | | |
696 | | - | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
697 | 706 | | |
698 | 707 | | |
699 | 708 | | |
700 | | - | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
701 | 712 | | |
702 | 713 | | |
703 | 714 | | |
704 | 715 | | |
705 | 716 | | |
706 | 717 | | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
707 | 737 | | |
708 | 738 | | |
709 | 739 | | |
| |||
739 | 769 | | |
740 | 770 | | |
741 | 771 | | |
742 | | - | |
743 | | - | |
744 | | - | |
745 | | - | |
746 | | - | |
747 | | - | |
748 | | - | |
749 | | - | |
750 | | - | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
751 | 777 | | |
752 | 778 | | |
753 | 779 | | |
| |||
779 | 805 | | |
780 | 806 | | |
781 | 807 | | |
782 | | - | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
783 | 812 | | |
784 | 813 | | |
785 | 814 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
161 | 161 | | |
162 | 162 | | |
163 | 163 | | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
181 | 219 | | |
182 | 220 | | |
183 | 221 | | |
| |||
0 commit comments