Skip to content

Add E03posix_013.zsh to corpus skip list and baseline - #3502

Closed
agoodkind wants to merge 44 commits into
koalaman:masterfrom
agoodkind:fix/ci-zsh-golden
Closed

Add E03posix_013.zsh to corpus skip list and baseline#3502
agoodkind wants to merge 44 commits into
koalaman:masterfrom
agoodkind:fix/ci-zsh-golden

Conversation

@agoodkind

Copy link
Copy Markdown

Summary

Master CI Zsh golden fixtures fails because E03posix_013.zsh newly appears in the corpus parse-failure list and is not in test/zsh/corpus-parse-failures.txt.

That chunk comes from upstream zsh Test/E03posix.ztst chunk 13, which is missing the closing quote on -c 'end() { true; } (the sibling foreach line has the quote). ShellCheck correctly reports SC1073/SC1072.

Changes

  • Add E03posix_013.zsh to DOCUMENTED_ERROR_TEST_SKIPS in test/zsh/corpus-report.sh
  • Regenerate test/zsh/corpus-parse-failures.txt (10 of 2914 raw failures; 0 effective / 100.00%)

Test plan

  • ./test/zsh/extract-ztst.sh against zsh c0fe1189905e6bd6ef227068478638cfb52b1255
  • ./test/zsh/corpus-report.sh exits 0 with 0 effective ... (100.00%)
  • ./test/zsh/run-golden.sh --no-build (47 passed)
  • CI Zsh golden fixtures green on this PR

Made with Cursor

agoodkind and others added 30 commits December 29, 2025 17:00
- Fix T_ForShort variable tracking in AnalyzerLib, Analytics, and ASTLib
- Expand ZshParamFlag and GlobQual AST types from 11 to 21/25 variants
- Enhance parser with full ZSH parameter flags and glob qualifiers
- Integrate T_ForShort into loop analysis functions
- Add 16 ZSH-specific tests for short for loops, parameter flags, glob qualifiers, and anonymous functions
- Add ZSH test scripts for real-world validation
- All tests pass with no false positives for valid ZSH code
- Move all ZSH test files to test/zsh/ directory
- Add 15 comprehensive ZSH test files covering:
  * Unquoted variable expansion (SC2086)
  * Unused variables (SC2034)
  * Undefined variable references (SC2154)
  * ZSH short for loop variable tracking
  * Array usage issues (SC2128)
  * Quoting issues in conditions
  * Useless cat (SC2002)
  * ZSH parameter flags (no false positives)
  * ZSH glob qualifiers (valid syntax)
  * ZSH anonymous functions (valid syntax)
  * Common programming errors
  * Loop variable reassignment (SC2165)
  * File test operators
  * Globbing issues (SC2045)
  * Redirect and pipe issues (SC2094, SC2069, SC2261)
- Fix pattern match failures in AnalyzerLib.hs and Analytics.hs
  * Add Zsh cases to hasLastpipe, hasInheritErrexit, hasPipefail
  * Add Zsh case to checkFunctionDeclarations
- All ZSH test files now run without crashes
- ShellCheck successfully catches issues in test files
Implemented 16 new ZSH-specific checks:
- SC2407: always blocks (limited detection due to parse errors)
- SC2408: select loops (zsh/ksh feature)
- SC2409: brace expansion in POSIX sh (overlaps with SC3009)
- SC2410: glob exclusion patterns (*.c~lex.c)
- SC2411: approximate matching (limited detection)
- SC2412: null command shorthands (< file, > file)
- SC2413: named coprocesses
- SC2414: directory stack references (~1, ~+1, ~-1)
- SC2415: global aliases (alias -g)
- SC2416: suffix aliases (alias -s)
- SC2417: zsh-specific builtins (autoload, zmodload, etc.)
- SC2418: setopt/unsetopt commands
- SC2419: associative arrays with typeset -A
- SC2420: array subscript flags [(i), (r), etc.]
- SC2421: power operator (**)
- SC2422: math commands (merged into SC2417 for zcalc/zstat)

All checks include test files demonstrating the features.
- Fix T_ForShort variable tracking in AnalyzerLib, Analytics, and ASTLib
- Expand ZshParamFlag and GlobQual AST types from 11 to 21/25 variants
- Enhance parser with full ZSH parameter flags and glob qualifiers
- Integrate T_ForShort into loop analysis functions
- Add 16 ZSH-specific tests for short for loops, parameter flags, glob qualifiers, and anonymous functions
- Add ZSH test scripts for real-world validation
- All tests pass with no false positives for valid ZSH code
- Move all ZSH test files to test/zsh/ directory
- Add 15 comprehensive ZSH test files covering:
  * Unquoted variable expansion (SC2086)
  * Unused variables (SC2034)
  * Undefined variable references (SC2154)
  * ZSH short for loop variable tracking
  * Array usage issues (SC2128)
  * Quoting issues in conditions
  * Useless cat (SC2002)
  * ZSH parameter flags (no false positives)
  * ZSH glob qualifiers (valid syntax)
  * ZSH anonymous functions (valid syntax)
  * Common programming errors
  * Loop variable reassignment (SC2165)
  * File test operators
  * Globbing issues (SC2045)
  * Redirect and pipe issues (SC2094, SC2069, SC2261)
- Fix pattern match failures in AnalyzerLib.hs and Analytics.hs
  * Add Zsh cases to hasLastpipe, hasInheritErrexit, hasPipefail
  * Add Zsh case to checkFunctionDeclarations
- All ZSH test files now run without crashes
- ShellCheck successfully catches issues in test files
Implemented 16 new ZSH-specific checks:
- SC2407: always blocks (limited detection due to parse errors)
- SC2408: select loops (zsh/ksh feature)
- SC2409: brace expansion in POSIX sh (overlaps with SC3009)
- SC2410: glob exclusion patterns (*.c~lex.c)
- SC2411: approximate matching (limited detection)
- SC2412: null command shorthands (< file, > file)
- SC2413: named coprocesses
- SC2414: directory stack references (~1, ~+1, ~-1)
- SC2415: global aliases (alias -g)
- SC2416: suffix aliases (alias -s)
- SC2417: zsh-specific builtins (autoload, zmodload, etc.)
- SC2418: setopt/unsetopt commands
- SC2419: associative arrays with typeset -A
- SC2420: array subscript flags [(i), (r), etc.]
- SC2421: power operator (**)
- SC2422: math commands (merged into SC2417 for zcalc/zstat)

All checks include test files demonstrating the features.
Invert SC2412 to fire in zsh mode for NULLCMD semantics, restore RC
suppression test with csh shebang, and assert zsh shebang no longer
raises SC1071. Remove redundant SC2409/ExtGlob/Approx props deferred
to parser and SC24xx audit work.

Co-authored-by: Cursor <cursoragent@cursor.com>
run-golden.sh snapshots each fixture's shellcheck exit code and SC code set
so parser work can be measured against a committed baseline. Goldens that
still contain SC1xxx record outstanding parse failures.

Replaces test/zsh/test.sh, which hardcoded a developer-local path.

Co-authored-by: Cursor <cursoragent@cursor.com>
Thread qualifier parsing through readNormalishWord so *.ext(.) forms
emit T_GlobQualifier without tripping bash SC1036. SC2401 now targets
unambiguous zsh-only qualifiers; bash extglob *(.) stays T_Extglob.
Restore SC2419 bash guard and test sh portability instead of bash.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
The parser now tracks the dialect resolved from -s, a shell= directive or
the shebang, because zsh recognizes '}' as a reserved word in any position
(Doc/Zsh/grammar.yo). That lets '{ echo hi }' and nested anonymous functions
close without a separator in zsh while bash keeps its SC1083/SC1056 reports.

Also adds the 'function { ... } args' anonymous spelling from Doc/Zsh/func.yo,
stops anonymous function arguments from swallowing the following line, and
parses '{ list } always { list }' in every dialect so SC2407 reports a
portability problem instead of leaving a parse error. SC2407 no longer fires
on any word that happens to be "always".

Co-authored-by: Cursor <cursoragent@cursor.com>
Add real setopt/unsetopt/set -o tracking so checks can ask whether a zsh
option is in effect, then use it where zsh differs from bash:

- supportsArrays Zsh = True and hasLastpipe Zsh = True
- SC2128 stays quiet unless KSH_ARRAYS is set, since zsh expands an
  unindexed array to all elements
- SC2404 stays quiet under KSH_ARRAYS, which makes arrays 0-based
- SC2086 gets zsh wording, because zsh does not word split or glob
  unquoted scalars without SH_WORD_SPLIT or GLOB_SUBST
- SC2406 previously matched a glob token the parser never produces for
  '^foo'. It now reports the verifiable case: extended_glob is set, so an
  unquoted leading caret negates the pattern.

run-golden.sh now builds the executable first, since cabal test does not
relink it and the goldens would compare against a stale binary.

Co-authored-by: Cursor <cursoragent@cursor.com>
Verified each zsh code against the shells it names, then removed the ones
that were either already covered or contradicted by the shells:

- SC2409, SC2421 and SC2422 duplicated SC3009, SC3019 and SC3006
- SC2410 fired on any literal tilde, so 'cd ~user' was a glob exclusion
- SC2411 matched a literal '(#' the parser never produces

Corrected guards and messages where the claim was wrong:

- SC2405 now reports BASH_REMATCH in zsh, which zsh never sets, instead of
  claiming =~ works differently
- SC2408: bash has select, so this is now a POSIX sh warning
- SC2413: bash accepts 'coproc NAME { }' and zsh does not, so the warning
  was backwards
- SC2414: bash expands ~1 against the dirstack too
- SC2417: 'which' is an ordinary command, and autoload and whence are ksh
  builtins as well
- SC2419: ksh93 has typeset -A

SC2188 no longer fires in zsh, where a bare redirection runs $NULLCMD and
SC2412 already says so.

Co-authored-by: Cursor <cursoragent@cursor.com>
- $arr[2] reads the subscript into the expansion in zsh scripts, since zsh
  subscripts a bare expansion. SC1087 no longer demands braces there, and
  SC2404 now sees $arr[0] as well as ${arr[0]}.
- =(...) joins <(...) and >(...) as a process substitution in zsh, where it
  writes to a temp file so the command can seek.
- 'foreach name (words) list end' parses as a for..in loop. Both foreach and
  end are zsh reserved words, so 'end' is only a keyword in zsh scripts.
- SC2261 no longer reports repeated redirections in zsh, where MULTIOS tees
  to every target by default. It fires again after 'unsetopt multios'.

Co-authored-by: Cursor <cursoragent@cursor.com>
Extract zsh's own test chunks into a gitignored corpus directory, track
parse failures against a committed baseline, and run the report in CI
alongside the golden fixture job.

Co-authored-by: Cursor <cursoragent@cursor.com>
List zsh in README, man page, --help, and CHANGELOG; replace the stale
implementation summary with a PR-ready checklist for the operator.

Co-authored-by: Cursor <cursoragent@cursor.com>
The zsh addition left a run of spaces mid-sentence and an overlong line in
the --shell description. PR-READY.md is a working note for this branch, not
something upstream should carry, so it moves to .superpowers/sdd/.

Co-authored-by: Cursor <cursoragent@cursor.com>
The zsh-only names had been appended to the shared internalVariables and
arrayVariables lists, so bash scripts stopped getting SC2154 for $status
and $reply and got SC2128 treatment for $path. Split them into
zshInternalVariables and zshArrayVariables behind internalVariablesFor and
arrayVariablesFor, and register the arrays that a bare zsh already defines
(path, manpath, cdpath, mailpath, psvar) as internal.

Co-authored-by: Cursor <cursoragent@cursor.com>
The baseline is committed, so naming a machine-specific directory made the
provenance header useless to anyone else. Record the origin URL and the full
commit instead, which is what the CI job pins.

Co-authored-by: Cursor <cursoragent@cursor.com>
zsh allows digit-leading iterator names in for/foreach; extend the loop
parsers with readZshLoopVariableName so corpus harness wrappers parse.

Co-authored-by: Cursor <cursoragent@cursor.com>
Add readFuncCall to readArithmeticContents so builtins like atan(1.0) and
min(42, 43) parse inside (( )) and $(( )).

Co-authored-by: Cursor <cursoragent@cursor.com>
agoodkind and others added 14 commits July 26, 2026 16:28
Add readZshCondWord for (#cN) and (#q.) style approximate-glob prefixes
so D02glob and C02cond corpus chunks parse without SC1036 false positives.

Co-authored-by: Cursor <cursoragent@cursor.com>
Reflects numeric for names, arithmetic funcalls, and extended glob in [[ ]].

Co-authored-by: Cursor <cursoragent@cursor.com>
Stop assignment words at } inside brace-command context, add readZshDoubleBraceNofork with optional var-close and newline body, and allow trailing space before ${| closing brace. Corpus baseline 151 to 134 failures.

Co-authored-by: Cursor <cursoragent@cursor.com>
Support null `!` before separators, zsh short if/case/for, braced loop
bodies, and multi-name functions. Corpus baseline drops to 107/2914 (27
A01 chunks cleared); corpus-report.sh skips documented D10/A01 error tests.

Co-authored-by: Cursor <cursoragent@cursor.com>
Handle (pat|pat) groups in [[ ]], colon-nested parameter flags like
${(g:o:)var}, and zsh if/elif with newline before then. Clears 47
corpus chunks (107→60 raw, 98→51 effective).

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Support empty brace bodies, f$$ names, braceless function/anon bodies,
multi-name fn defs, repeat loops, array {word} elements, bare (pat|pat)
in words and [[ ]], zsh [ ] trailing operands, and newline-then if.
Clears 11 effective corpus chunks (51→40).

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Fix here-doc delimiter reconstruction for quoted zsh words, nested parameter
flag colon sections, and backtick raw bodies. Restore bash here-doc quoting and
function-name guards while keeping zsh-only condition and reserved-name rules.
Update the corpus baseline to the nine documented D10 error-test skips only.

Co-authored-by: Cursor <cursoragent@cursor.com>
Resolve conflicts in favor of the zsh dialect branch and bring in upstream
sync workflow assets from fork master. Regenerate zsh golden files for merged
test additions.

Co-authored-by: Cursor <cursoragent@cursor.com>
Add first-class zsh dialect support
Co-authored-by: Cursor <cursoragent@cursor.com>
Copilot AI review requested due to automatic review settings July 27, 2026 05:30

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@agoodkind

Copy link
Copy Markdown
Author

Opened against the wrong repository by mistake. This change is for the agoodkind/shellcheck zsh-dialect fork CI corpus gate, not upstream ShellCheck.

@agoodkind agoodkind closed this Jul 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants