Commit ddce4c7
authored
PR 4: BashResolver + per-verb path rules + flag-aware verb probe (#7)
* PR 4: BashResolver + per-verb path rules + flag-aware verb probe
Implements SPEC §8 (resolver) and SPEC §7 (per-verb path-arg rules) +
the flag-with-value-aware verb-chain probe deferred from PR 3. Locked
interpretations #3 (Glob vs DynamicSkip distinction) and #8 (tar /
docker -v default rule) materialized.
What's wired:
- Internal/Resolving/BashResolver.cs (SPEC §8 pipeline):
* filesystem:: prefix strip
* tilde + $HOME expansion (HomeDirectory lazy fallback to
Environment.SpecialFolder.UserProfile)
* other $VAR/${VAR} in path slot → Kind=DynamicSkip, IsPath=false
* other $VAR in non-path slot → Kind=EnvVar
* glob detection: Kind=Glob, IsPath=true in path slot (covering-dir
heuristic preserved per locked #3)
* relative-path join against WorkingDirectory (lazy fallback to
Environment.CurrentDirectory)
* LooksLikePath heuristic with curated extension list
* IOException / path-format exception → DynamicSkip per SPEC §8 step 6
- Internal/Bash/Verbs/BashPerVerbRules.cs (SPEC §7):
* Per-positional rules: chmod (mode/path), chown (user/path), chgrp
(group/path), ln (all paths), find (path/predicates), grep/rg
(pattern/paths), sed/awk (script/paths), tar (default rule per #8),
curl/wget (URL not path; -o/-O values are paths), scp/rsync/sftp
(all paths), cd-family (target path)
* Default rule for FileVerbs without override: all non-flag
positionals are paths
* LooksLikePath fallback for non-FileVerbs
* Flag-value path classification: git -C / --git-dir is path;
curl -d/--data is body data not path; docker -v is single literal
IsPath=false per locked #8; tar -f/-C are paths
- BashCommandParser updates:
* Flag-with-value-aware verb-chain probe — `git -C /repo log` →
Verb.Tokens=["git", "log"] per SPEC §12 example (deferred from PR 3)
* Resolver wired into Arg construction
* Redirect.Target = Resolved when resolvable; IsDynamicSkip=true
otherwise
Tests:
- BashResolverTests: 34 tests covering tilde/$HOME/env-var/glob/
filesystem::/abs/rel/LooksLikePath
- BashPerVerbRulesTests: 34 tests covering each per-verb rule + flag-
value classification
- BashCommandParserTests: 9 new tests + refresh of PR 3 tests with
HomeDirectory=/home/test, WorkingDirectory=/work
- 12 existing corpus entries refreshed for path classification
- 20 new corpus entries (51-70):
* 51-60 dynamic-skip: $UNRESOLVED/foo, $REPO patterns, $HOME expansion,
$LOG_FILE, ${PATH}/bin/foo, glob in path slot
* 61-70 per-verb rules: chmod 755 path, chown user:group path, find
/var/log -name "*.log", grep pattern path, sed script path, awk
program path, curl -o path URL, wget -O path URL, git -C /repo log,
tar -xf archive target
Total tests: 296/296 passing. Public API surface unchanged.
SPEC.md §8 updated:
- Step 4 explicitly states Glob has IsPath=true in path-arg slot and
IsPath=false elsewhere; preserves covering-dir heuristic
- Step 6 narrows DynamicSkip to env-var-in-path-slot and resolver-throws
cases (no longer overlaps with Glob)
- Glob and DynamicSkip carry distinct signals per locked #3
PR 4 → PR 5 follow-ups tracked in tasks.md:
- Subshell IsSubshell flag wiring (Segment.FromSubshell plumbed but
unused)
- cd-attribution propagation via internal-context-state piggybacked on
parsing pipeline
- locked #6 (cd $VAR propagation) DynamicSkip cwd signal
* Fix(resolver): produce bash-style paths on Windows
Path.GetFullPath is platform-aware. On Windows it expands `/etc/hosts`
to `D:\etc\hosts` because Windows treats `/` as drive-relative. This
breaks 53 tests on Test-windows-latest CI runner.
Bash semantics use forward slashes universally regardless of host OS,
so the resolver now string-only normalizes paths:
- NormalizeToForwardSlashes: \\ → / (preserves UNC as //server/share)
- NormalizePath: split on /, collapse . and .., dedupe slashes,
preserve leading / (or //, or X: drive letter), join with /
- TryResolveAbsolutePath uses these helpers instead of Path.GetFullPath
- JoinPath uses string concat with explicit / instead of Path.Combine
Linux: still 296/296 green. Windows runner should now pass — the
`Expected /work/input vs Actual D:\work\input` failures all disappear
because the resolver no longer touches the host's PathSeparator.1 parent 325fa6f commit ddce4c7
42 files changed
Lines changed: 2553 additions & 287 deletions
File tree
- openspec/changes/v0.1-locked-interpretations
- src/ShellSyntaxTree/Internal
- Bash
- Parsing
- Verbs
- Resolving
- tests/ShellSyntaxTree.Tests
- Corpus
- bash
- Parsing
- Resolving
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 | |
|---|---|---|---|
| |||
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
110 | 116 | | |
111 | 117 | | |
112 | 118 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
621 | 621 | | |
622 | 622 | | |
623 | 623 | | |
624 | | - | |
625 | | - | |
626 | | - | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
627 | 636 | | |
628 | 637 | | |
629 | | - | |
630 | | - | |
631 | | - | |
632 | | - | |
633 | | - | |
634 | | - | |
635 | | - | |
636 | | - | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
637 | 648 | | |
638 | 649 | | |
639 | | - | |
640 | | - | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
641 | 653 | | |
642 | 654 | | |
643 | 655 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
106 | 106 | | |
107 | 107 | | |
108 | 108 | | |
109 | | - | |
110 | | - | |
111 | | - | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
112 | 116 | | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
124 | 161 | | |
125 | 162 | | |
126 | 163 | | |
| |||
0 commit comments