GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||
GeezerVison is showing github.com — fix(core): make the portable PowerShell scanner sound against real pwsh by kitlangton · Pull Request #53404 · anomalyco/opencode Conversation
|
| Input | Before | After |
|---|---|---|
$x = "$(switch ${x}#)\n{ default { Invoke-ProbeA } })" |
[] |
Invoke-ProbeA |
${x}<# comment #>; Invoke-ProbeA |
[] |
Invoke-ProbeA |
"$("a""; Invoke-ProbeA; "b"")" |
[] |
Invoke-ProbeA |
${a`u{0041}'}; Invoke-ProbeA; #' |
[] |
Invoke-ProbeA |
$probe[-$(Invoke-ProbeA)] |
[] |
Invoke-ProbeA |
Write-Output [a; Invoke-ProbeA; Write-Output ] |
Write-Output only |
Write-Output, Invoke-ProbeA, Write-Output |
ssh user@'host' |
opaque (fails) |
ssh |
Set-Location -p:/outside, -l:/outside, '-outside', /out`side |
directories: [] |
directories: ["/outside"] (or ["-outside"]) |
ForEach-Object -InputObject $proc -MemberName Kill |
commands: [] |
ForEach-Object |
( ... ), { ... }, [ ... ], $( ... ), @( ... ), @{ ... }, and "..." / @"..."@ subexpressions recurse directly into scanPowerShellList(input, start, depth, budget, close, hash) and end where the inner parse ends.@"..."@ & ${...} escapes: expandable here-strings scan ` escapes, ${...} (via powerShellBracedVariable, including `u{...}), and $(...) inline while searching for the closing \n"@, so \n"@ inside a subexpression cannot close the outer here-string early."$(...)": tracks inDoubleQuote across subexpressions inside "..." so "" closes inner double-quoted strings and """" represents an escaped quote, matching PowerShell's lexer.until, else/elseif, catch/finally, and param only enter compound headers in their valid syntactic context; <# ... #> is recognized after expression tokens without misclassifying mid-word # in bareword switch conditions or data -SupportedCommand arguments.input.slice(index) regexes with hoisted sticky /.../y regexes and collapses the 5 compound-header booleans into one clause state.This PR touches only the PowerShell scanner in packages/core/src/shell/scan.ts (the Bash section is byte-identical to v2), PowerShell directory/command handling in packages/core/src/shell/parse.ts, and the PowerShell test suites. Tree-sitter remains the default behind experimental.portable_shell_scanner.
cd packages/core SHELL_SCAN_PWSH=/path/to/pwsh SHELL_ORACLE_STRICT=1 bun run test test/shell-scan test/shell-parse-parity.test.ts test/shell-parse-compatibility.test.ts test/shell-parse-syntax.test.ts test/shell-parse.test.ts test/tool-shell.test.ts bun typecheck cd ../.. && bun run check
powershell-runtime.test.ts): verified against [System.Management.Automation.Language.Parser]::ParseInput and runtime execution in PowerShell 7.6.6.bun run check passes all 36/36 tasks.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…member access with pwsh
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.