From e5d13e101de909b69a33cfe26e243148df8cbf51 Mon Sep 17 00:00:00 2001 From: Nick Bowler Date: Sat, 7 Jan 2023 23:14:56 -0500 Subject: [PATCH] gen-options.awk: Fix generated help text under mawk. It appears that the following construction is not portable: % gawk 'BEGIN { a[0] = 0 in a ? 54 : 42; print a[0]; }' 42 % mawk 'BEGIN { a[0] = 0 in a ? 54 : 42; print a[0]; }' 54 In gen-options.awk, this results in results in bogus leading newlines added to the help text. It is easy enough to restructure the code to not do that, separating the test from the assignment. --- scripts/gen-options.awk | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/gen-options.awk b/scripts/gen-options.awk index 679dc99..f1dbb1c 100755 --- a/scripts/gen-options.awk +++ b/scripts/gen-options.awk @@ -213,7 +213,9 @@ lopt { sub(/^[ \t]*/, "") if (!$0) { next } - optionhelp[lopt] = (lopt in optionhelp ? optionhelp[lopt] "\n" : "") $0 + if (lopt in optionhelp) + $0 = "\n" $0; + optionhelp[lopt] = optionhelp[lopt] $0; } # Exit immediately on error -- 2.43.2