branch: elpa/flycheck
commit 9cfc75b10381e7a51db9a96a38f2d39ec44e432b
Author: Bozhidar Batsov <[email protected]>
Commit: Bozhidar Batsov <[email protected]>
[Fix #2166] Stop awk-gawk flagging valid scripts
The lint harness forced "END{exit 1}", so gawk always exited non-zero
even for clean scripts, tripping flycheck's "returned 1 but no errors"
warning. Flycheck reads lint output from stderr regardless of exit
code, so the forced failure served no purpose. Use "END{exit}" instead;
the END block is still needed to short-circuit the script's own rules.
---
CHANGES.rst | 2 ++
flycheck.el | 5 ++++-
test/resources/language/awk/valid.awk | 3 +++
test/specs/languages/test-awk.el | 9 ++++++++-
4 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/CHANGES.rst b/CHANGES.rst
index 0bf93ddfb3..39fdd063a7 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -4,6 +4,8 @@
- Add ``neocaml-opam-mode`` support to the ``opam`` checker.
- [#2169]: Parse the severity-tagged output format introduced by Ruff 0.15.7
in preview mode (e.g. ``error[F401]`` instead of ``F401``).
+- [#2166]: Fix ``awk-gawk`` reporting a suspicious checker state for valid
+ scripts.
36.0 (2026-02-19)
======================
diff --git a/flycheck.el b/flycheck.el
index e18d1f9a30..2c14a298a5 100644
--- a/flycheck.el
+++ b/flycheck.el
@@ -7552,7 +7552,10 @@ See URL `https://asciidoctor.org'."
"GNU awk's built-in --lint checker."
:command ("gawk"
;; Avoid code execution. See https://github.com/w0rp/ale/pull/1411
- "--source" "BEGIN{exit} END{exit 1}"
+ ;; The BEGIN/END blocks short-circuit the script's own rules so
+ ;; only linting happens; exit 0 so that valid scripts don't get
+ ;; flagged as a suspicious non-zero exit.
+ "--source" "BEGIN{exit} END{exit}"
"-f" source
"--lint"
"/dev/null")
diff --git a/test/resources/language/awk/valid.awk
b/test/resources/language/awk/valid.awk
new file mode 100644
index 0000000000..59ddec8e25
--- /dev/null
+++ b/test/resources/language/awk/valid.awk
@@ -0,0 +1,3 @@
+BEGIN { print "hello" }
+{ print toupper($0) }
+END { print "world" }
diff --git a/test/specs/languages/test-awk.el b/test/specs/languages/test-awk.el
index 64d43b9050..23f0654f82 100644
--- a/test/specs/languages/test-awk.el
+++ b/test/specs/languages/test-awk.el
@@ -7,6 +7,13 @@
(flycheck-buttercup-def-checker-test awk-gawk awk syntax-error
(flycheck-buttercup-should-syntax-check
"language/awk/syntax-error.awk" 'awk-mode
- '(2 nil warning "x=|\n ^ syntax error" :checker awk-gawk))))
+ '(2 nil warning "x=|\n ^ syntax error" :checker awk-gawk)))
+
+ (flycheck-buttercup-def-checker-test awk-gawk awk valid
+ ;; A valid script must not be flagged just because gawk's lint
+ ;; harness exits non-zero. See URL
+ ;; `https://github.com/flycheck/flycheck/issues/2166'.
+ (flycheck-buttercup-should-syntax-check
+ "language/awk/valid.awk" 'awk-mode)))
;;; test-awk.el ends here