Add E03posix_013.zsh to corpus skip list and baseline - #3502
Closed
agoodkind wants to merge 44 commits into
Closed
Conversation
- 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>
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>
Author
|
Opened against the wrong repository by mistake. This change is for the agoodkind/shellcheck zsh-dialect fork CI corpus gate, not upstream ShellCheck. |
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.
Summary
Master CI
Zsh golden fixturesfails becauseE03posix_013.zshnewly appears in the corpus parse-failure list and is not intest/zsh/corpus-parse-failures.txt.That chunk comes from upstream zsh
Test/E03posix.ztstchunk 13, which is missing the closing quote on-c 'end() { true; }(the siblingforeachline has the quote). ShellCheck correctly reports SC1073/SC1072.Changes
E03posix_013.zshtoDOCUMENTED_ERROR_TEST_SKIPSintest/zsh/corpus-report.shtest/zsh/corpus-parse-failures.txt(10 of 2914 raw failures; 0 effective / 100.00%)Test plan
./test/zsh/extract-ztst.shagainst zshc0fe1189905e6bd6ef227068478638cfb52b1255./test/zsh/corpus-report.shexits 0 with0 effective ... (100.00%)./test/zsh/run-golden.sh --no-build(47 passed)Zsh golden fixturesgreen on this PRMade with Cursor