Repository navigation
fix(diag): route compgen -F error via builtin stderr; honor gnu_errfmt - #1131
Merged
Merged
Conversation
…r gnu_errfmt (rubash#1041, rubash#1038) bypassing the builtin's redirects and emitting before the buffered -F warning. Route the pcomplete.c:1058-1066 internal_error diagnostic through the caller's stderr buffer so `compgen -F f -- "" 2>e.txt >o.txt` lands both lines in e.txt in order (rc 1, o.txt empty). error_prefix()/parser_error_prefix() (+ _for_line twins, comsub variant) implementing the error.c:83 / :300-316 gate (`file:N: ` vs `file: line N: `), and switch the whole error_prolog/parser_error family onto it: command-not-found/slash-execve (execute_cmd.c internal_error), arithmetic evalerror/bad-substitution (expr.c, subst.c report_error), redirection_error (redir.c:135), wait pid (jobs.c JWAIT_PERROR), err_readonly/err_badarraysub/err_unboundvar (error.c), nameref warnings (internal_warning), parser/syntax errors and heredoc warnings (parser_error/report_syntax_error). Builtin errors (common.c builtin_error_prolog: cd, compgen warning, jobs, declare sh_readonly, sh_chkwrite, select/read invalid-id) keep the ungated prefix — verified against GNU 5.3.20, including the compgen split (warning ungated, lookup gated) and the wait split. New tests: tests/issue1041_compgen_missing_function_redirect.rs, tests/issue1038_gnu_errfmt_prefix.rs. Verified: lib 693 green, new tests green, related integration suites green, executor_tests delta vs base is timing flakes only (kill/ulimit/signal-number cases fail identically on unmodified base on this box). Debug + release binaries both reproduce GNU byte-for-byte on the issue scripts. Known gaps (unchanged from base, C ownership unsettled): - `declare -a/-A/-i/-l/-u <compound>` on readonly reports ungated bare while `declare <compound>` gates; both collapse into one rubash pre-check (kept ungated = old behavior). - `t=X cmd` tempenv / `read v` readonly carry a `cmd: ` segment GNU omits (pre-existing); only the line segment is now gated.
caomengxuan666
force-pushed
the
fix/diag-routing
branch
from
October 23, 2026 01:20
7a47514 to
6c6d523
Compare
Member
Author
|
Rebased onto post-#1181 master and force-pushed as |
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 #1041, closes #1038. (1) compgen -F missing-function diagnostic bypassed all redirections via session-stderr eprintln (and out of order); now goes through the caller's stderr buffer after the -F warning, matching GNU pcomplete.c internal_error routing. (2) gnu_errfmt was in the shopt table but never queried; new error_prefix()/parser_error_prefix() (+comsub variants) gate error.c's error_prolog/parser_error families (command-not-found, arith evalerror, redirect errors, wait pid, readonly/badsubscript/unbound/nameref, parser/syntax/heredoc), while builtin-family messages (cd, compgen warning, jobs, declare sh_readonly...) stay ungated per GNU builtins/common.c. Tests: lib 693 + 6 new + 60+ redirect/arith/parse/nounset/declare/heredoc/trap suites green, executor_tests delta-free vs base; GNU parity byte-identical incl. rc and redirect files. Known gaps (pre-existing, unchanged): declare -a/-A/-i/-l/-u compound on readonly; tempenv/read cmd: segment.