Repository navigation
One shell reader, three dialects: read cmd steps and batch files as cmd, PowerShell scripts as PowerShell - #370
Merged
Conversation
The shell reader read PowerShell through a `powershell: bool` threaded from `parse` through the lexer, the parser, `split_script`, `script_facts` and the CI readers, each branch asking it what it meant: the escape character, whether compound commands are parsed, whether `$'…'` and backquoted substitution are quoting. A third shell would have had every one of them learn of it. A `Dialect` now says those things, and the reader asks it: `POSIX` and `POWERSHELL` read as before. Callers name the dialect (`dialect=POWERSHELL`). No behaviour changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ByTXNqDWdM7HzezrFtEvQt
…itHub's `shell: cmd` A `shell: cmd` step was split by the POSIX shell's rules. A backslash, a path separator in cmd, escaped the next character (`build\Release\app.exe` ran `buildReleaseapp.exe`); cmd's `if not exist build mkdir build` ran a program named `not`; `^` continued nothing. `CMD` is a dialect of the same reader: `^` escapes and continues a line (not in double quotes, where it is text); only `"` quotes; `REM` and `::` start a comment where a command starts; there is no `;` operator, and no `$` substitution. Parentheses hold blocks where cmd opens one (where a command starts, after an `if`'s test, `else` or `do`); elsewhere (`%ProgramFiles(x86)%`) they are text. The command a line runs is found past `@`, an `if`'s test, a `for`'s loop, `else` and `call`; a label runs nothing. GitHub's steps are read in the dialect of their shell: `cmd`, `pwsh`/`powershell`, or a POSIX shell. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ByTXNqDWdM7HzezrFtEvQt
…hell's dialect The script-file expander followed only POSIX shell scripts. A batch file CI runs (`scripts\build.bat`, `call ci\setup.bat`, `cmd /c build.bat`) and a PowerShell script (`./ci/test.ps1`, `pwsh -File ci/test.ps1`) are now followed the same way, their text read in cmd's or PowerShell's dialect (`Script.dialect`), their paths written with slashes. One the project does not hold is unknown, as a missing shell script is; one elsewhere (`C:\BuildTools\vcvars64.bat`) is not followed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ByTXNqDWdM7HzezrFtEvQt
…ned heuristically as cmd Two things the corpus showed once batch files and PowerShell scripts were followed: - A batch file the project does not hold is most often a program (`npm.cmd`) or generated in CI (Composer's `vendor/bin/phpunit.bat`), not a script that went missing: it is not followed, and not reported unknown. A missing POSIX shell script still is. - A CI file scanned heuristically (Azure Pipelines, AppVeyor) was read as a POSIX script on every OS, so the backslashes of a Windows path were taken for escapes (`.\Build\runbuild.ps1` ran `.Buildrunbuild.ps1`). A Windows job's lines are read as cmd's, as they are most often written. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ByTXNqDWdM7HzezrFtEvQt
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #370 +/- ##
==========================================
- Coverage 99.72% 99.70% -0.02%
==========================================
Files 313 313
Lines 19984 20097 +113
Branches 2337 2363 +26
==========================================
+ Hits 19929 20038 +109
- Misses 55 59 +4 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #300 (principle 8: the shell reader is the hub). One shell reader now reads POSIX sh, PowerShell and Windows's cmd, as three dialects of the same lexer and parser.
Why
A GitHub
shell: cmdstep was split by the POSIX shell's rules:build\Release\app.exeranbuildReleaseapp.exe.if not exist build mkdir buildran a program namednot.^continued nothing.12 corpus projects use
shell: cmd, among them fmt, Catch2, llama.cpp, opam, pgvector and h3.Commits
Dialectin place of thepowershell: boolflag. The flag was threaded throughparse, the lexer, the parser,split_script,script_factsand the CI readers, so a third shell would have needed every one of them to change. ADialectnow says how its shell reads a script: its escape character, compound commands, quoting, substitutions, the characters that end a word, comments, and blocks.POSIXandPOWERSHELLread exactly as before. This commit changes no behaviour.CMD, a third dialect of the same reader, used for GitHub'sshell: cmd:^escapes and continues a line, except inside double quotes, where it is text. Only"quotes.REMand::start one where a command starts.;operator and no$substitution.if's test,elseordo. Elsewhere they are text, so%ProgramFiles(x86)%stays one word.@, anif's test, afor's loop,elseandcall. A label runs nothing.Script.dialect. Batch files are reached asscripts\build.bat,call ci\setup.batorcmd /c build.bat; PowerShell scripts as./ci/test.ps1orpwsh -File ci/test.ps1.npm.cmd) or files CI generates (Composer'svendor/bin/phpunit.bat), so they are neither followed nor reported as missing scripts..\Build\runbuild.ps1keeps its backslashes.Corpus: 10 of 235 projects differ; no check's result changes
.gitlab-ci\test-msvc.batis followed, showing their Python and meson Debug build.cmdsteps now show MSVC, Debug and Release builds, and the Zig version.win-build-sycl.batis followed, showingicx(Intel) and Release. It also lists gcc, because the existing compiler detection matches its"MinGW Makefiles"generator; that detection quirk predates this PR.cmdsteps show gcc.Verified: all local gates pass. Every new behaviour was test first, with the RED run seen.
🤖 Generated with Claude Code
https://claude.ai/code/session_01ByTXNqDWdM7HzezrFtEvQt