Repository navigation
fix(compat): converge compat-level plumbing - #1173
Merged
Merged
Conversation
GNU owners: builtins/shopt.def:654-741 set_compatibility_level / set_compatibility_opts, variables.c:6457-6508 sv_shcompat, version.c:54-55, builtins/set.def:974, arrayfunc.c:1152-1200 + 1511-1545 unbind_array_element / array_value_internal, test.c:664-681 unary_operator -v, execute_cmd.c:4048-4057. Root cause: the compat level was keyed on a loose BASH_COMPAT parse only (support_names.rs, no strict spelling, no range check). shopt -s/-u compatNN never synced it (BASH_COMPAT= never synced the flags back), flags were not mutually exclusive, and bare shopt could not show a BASH_COMPAT-driven level. unset VA_ALLOWALL and test -v AV_ATSTARKEYS therefore only reacted to BASH_COMPAT spellings, never to shopt flags. Single plumbing in src/builtins/shopt/compat.rs: a set compatNN flag wins (GNU priority order), else the strict sv_shcompat parse (exact NN / N.N, 31..=default 53; invalid resets the level, keeps the raw string, reports `compatibility value out of range`, assignment still status 0), else 53. All readers (unset, test -v, [[ -v ]], =~ quoted-RHS) go through compatibility_level(); shopt -s/-u rebinds BASH_COMPAT (mutual exclusion, oldval>44 keep guard, readonly refusal without status change); every bind/restore path (bare declare local export readonly read temp-prefix, function-local restore, startup import, unset) re-syncs the flags. Assoc test -v 'K[@]' is any-element under compat and a literal-key lookup otherwise (bare @/* passes the -v rewrites unencoded only in compat mode; bind paths always encode literally). Dual-store: the shopt BASH_COMPAT rebind re-syncs the typed owner. Verified: 30 new regression tests + 21-case byte-identical script-file ledger vs bash 5.3.20 (stdout/stderr/rc); lib 698 green; related shopt / unset / declare / assoc / array / cond suites green (executor_tests failures are pre-existing platform ones, reproduced on stashed master).
caomengxuan666
force-pushed
the
fix/compat-plumbing
branch
from
October 23, 2026 01:04
a0e960a to
6a23eb5
Compare
Member
Author
|
Rebased onto post-#1181 master ( |
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.
Closes #1107, closes #1108. Root convergence: compat level becomes a single derivation (shopt flags in GNU mutex order win, else strict BASH_COMPAT parse NN/N.N in 31..53 else reset+keep-string+out-of-range diagnostic, default 53). shopt -s/-u now mutually exclusive + writes BASH_COMPAT back (oldval>44 keep-guard, readonly refuses write but still sets flag, rc 0); all bind/restore paths (bare/declare/local/export/readonly/read/temp-prefix/function-local restore/startup/unset) resync flags; conditional =~ reads the derived level. Assoc @/*: test -v/[[ -v ]] pass through in compat mode, bind path always literal-key. Tests: lib 699 + 30 new regression + shopt/unset/declare/assoc/array/cond suites green, executor_tests delta-free vs clean tree; 21 GNU parity probes + 10 scripts byte-identical. Known cosmetic: function-local restore of invalid values reports at the definition line.