mirror of
https://https.git.savannah.gnu.org/git/coreutils.git
synced 2026-01-25 23:17:53 +00:00
doc: use TERM=dumb rather than HELP_NO_MARKUP to disable markup
This is a more standard mechanism to disable markup. * src/system.h (oputs_): Logic change to honor TERM=dumb, rather than HELP_NO_MARKUP=something. * doc/coreutils.texi: Adjust the description for --help. * man/local.mk: Ensure TERM is set to something, so that man pages have links included. * man/viewman: Just honor users $TERM. * tests/misc/getopt_vs_usage.sh: Remove env var complication, as TERM is unset automatically. * tests/misc/usage_vs_refs.sh: Likewise. * NEWS: Adjust the change in behavior note.
This commit is contained in:
parent
bdc45990c7
commit
87219034b7
2
NEWS
2
NEWS
@ -70,7 +70,7 @@ GNU coreutils NEWS -*- outline -*-
|
||||
with bold attributes, and hyperlinks into the online manual on gnu.org.
|
||||
The links can be configured with the --enable-manual-url configure option,
|
||||
and the bold highlighting with --disable-bold-man-page-references.
|
||||
At runtime all markup can be disabled by setting the HELP_NO_MARKUP env var.
|
||||
At runtime all markup can be disabled by with the TERM=dumb env var value.
|
||||
|
||||
'fmt' -w,--width no longer includes '\n' in the width of a line.
|
||||
I.e., the specified width is interpreted to be an _inclusive_ maximum.
|
||||
|
||||
@ -764,12 +764,12 @@ these programs, abbreviations of the long options are not always recognized.
|
||||
|
||||
@item --help
|
||||
@opindex --help
|
||||
@vindex HELP_NO_MARKUP
|
||||
@vindex TERM
|
||||
@cindex help, online
|
||||
Print a usage message listing all available options, then exit successfully.
|
||||
Help output may be marked up with terminal codes for formatting or
|
||||
hyperlinks, which can be disabled by setting the @env{HELP_NO_MARKUP}
|
||||
environment variable.
|
||||
hyperlinks, which can be disabled by unsetting the @env{TERM} environment
|
||||
variable, or setting it to the value @samp{dumb}.
|
||||
|
||||
@item --version
|
||||
@opindex --version
|
||||
|
||||
@ -27,7 +27,8 @@ if HAVE_PERL
|
||||
if BOLD_MAN_REFS
|
||||
help2man_OPTS=--bold-refs
|
||||
endif
|
||||
run_help2man = $(PERL) -- $(srcdir)/man/help2man --loose-indent $(help2man_OPTS)
|
||||
run_help2man = env TERM=not_dumb $(PERL) -- \
|
||||
$(srcdir)/man/help2man --loose-indent $(help2man_OPTS)
|
||||
else
|
||||
run_help2man = $(SHELL) $(srcdir)/man/dummy-man
|
||||
endif
|
||||
|
||||
@ -8,7 +8,6 @@
|
||||
# export MANPAGER=less
|
||||
|
||||
unset GROFF_NO_SGR
|
||||
unset HELP_NO_MARKUP
|
||||
|
||||
hdir=$(dirname "$0")
|
||||
|
||||
|
||||
13
src/system.h
13
src/system.h
@ -542,7 +542,7 @@ is_nul (void const *buf, size_t length)
|
||||
/* Output --option descriptions;
|
||||
formatted with ANSI format and hyperlink codes.
|
||||
Any postprocessors like help2man etc. are expected to handle this,
|
||||
though it can be disabled in edge cases with the HELP_NO_MARKUP env var. */
|
||||
though it can be disabled in edge cases with the TERM=dumb env var. */
|
||||
|
||||
#define oputs(option) oputs_ (PROGRAM_NAME, option)
|
||||
static inline void
|
||||
@ -554,13 +554,20 @@ oputs_ (MAYBE_UNUSED char const* program, char const *option)
|
||||
#else
|
||||
-1; /* Lookup. */
|
||||
#endif
|
||||
if (help_no_sgr == 1
|
||||
|| (help_no_sgr == -1 && (help_no_sgr = !!getenv ("HELP_NO_MARKUP"))))
|
||||
if (help_no_sgr == -1)
|
||||
{
|
||||
/* Note we don't consult isatty() since usually you
|
||||
would want markup when piping to grep/less etc. */
|
||||
char const *term = getenv ("TERM");
|
||||
help_no_sgr = (!term || !*term || streq (term, "dumb"));
|
||||
}
|
||||
if (help_no_sgr)
|
||||
{
|
||||
fputs (option, stdout);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
char const* first_word = option + strspn (option, " \t\n");
|
||||
char const *option_text = strchr (option, '-');
|
||||
if (!option_text)
|
||||
|
||||
@ -44,12 +44,12 @@ for prg in $built_programs; do
|
||||
got_option=false
|
||||
for opt in $(shortopts $sprg); do
|
||||
got_option=true
|
||||
env HELP_NO_MARKUP=1 $prg --help | grep -F -- " -$opt" >/dev/null ||
|
||||
env $prg --help | grep -F -- " -$opt" >/dev/null ||
|
||||
{ printf -- '%s -%s missing from --help\n' $sprg $opt >&2; fail=1; }
|
||||
done
|
||||
for opt in $(longopts $sprg); do
|
||||
got_option=true
|
||||
env HELP_NO_MARKUP=1 $prg --help | grep -F -- "--$opt" >/dev/null ||
|
||||
env $prg --help | grep -F -- "--$opt" >/dev/null ||
|
||||
{ printf -- '%s --%s missing from --help\n' $sprg $opt >&2; fail=1; }
|
||||
done
|
||||
test "$DEBUG" && test $got_option = false && echo No options for $prg ?
|
||||
|
||||
@ -25,7 +25,7 @@ longopts() { getopts $1 | cut -s -d'"' -f2; }
|
||||
getopts() {
|
||||
skip='--help|--version' # These refs treated specially
|
||||
|
||||
HELP_NO_MARKUP=1 env "$1" --help |
|
||||
env "$1" --help |
|
||||
grep -E '^( -| --)' | # find options
|
||||
grep -Ev -- " - |-M.*from first" | # exclude invalid matches
|
||||
sed -e 's/^ *//' -e's/ .*//' | # strip leading space and descriptions
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user