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.
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.
@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
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
# export MANPAGER=less
unset GROFF_NO_SGR
-unset HELP_NO_MARKUP
hdir=$(dirname "$0")
/* 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
#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)
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 ?
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