patch: (re)enable #ifdef processing within builtin help text
From:
Martin D Kealey
Subject:
patch: (re)enable #ifdef processing within builtin help text
Date:
Sat, 30 Aug 2025 15:39:10 +1000
I tried adding documentation for declare -c but discovered that it wasn't
honouring CASEMOD_CAPCASE.
Looking at mkbuiltins.c, that appears to be because of the way
that single_longdoc_strings is handled.
So I figured I should fix that too. Attached herewith a patch to implement
both.
This will alter the output of « help *cmd* » and « *cmd* --help » to omit
mention of options that are not compiled into the current shell; affected
commands include: « help cd » (-@), « help declare » (-a, -A, -c, -l, -u),
« help set » (-b, -B, -H, -m, -o history, -o emacs, -o vi, ), and « help
variables » (everything related to history).
(By the time I'd figured out how it works, I'd changed some variable names
to reflect "why" rather than "how", made write_file_headers
and write_file_footers more symmetric, fixed some anomalous uses of
0-vs-NULL, and incidentally cleaned up some whitespace. I've left these
changes in as well.)
-Martin
PS: I initially wondered whether I should simply remove the « -S » option,
but I've left it in for now. Under what circumstances would it be
preferable to put each line of text in a separate array entry? It does seem
like a lot of the "help" handling would be smaller and simpler if it was
all single multi-line strings rather than arrays of single line strings.