[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
a groff convenience for quoting man pages (was: if source command.sh & s
From: |
G. Branden Robinson |
Subject: |
a groff convenience for quoting man pages (was: if source command.sh & set -e issue) |
Date: |
Fri, 26 Jul 2024 11:27:36 -0500 |
Hi Chet,
At 2024-07-26T11:18:57-0400, Chet Ramey wrote:
> The man page says, about this scenario:
>
> "The shell does not exit if the command that fails is
> part of the command list immediately following a while
> or until keyword, part of the test following the if or
> elif reserved words, part of any command executed in a
> && or || list except the command following the final &&
> or ||, any command in a pipeline but the last, or if the
> command's return value is being inverted with !. If a
> compound command other than a subshell returns a non-
> zero status because a command failed while -e was being
> ignored, the shell does not exit."
Like you, I frequently have reason to quote man pages to people. The
adjustment of lines ends up looking a bit weird for people who read
email using a proportional font.[1] If you're running groff 1.23.0
(released July 2023) on the machine you send email from, you can tell it
to suppress adjustment to both margins on the fly, without changing any
configuration files or defaults.
I have a shell function called "mailman"--merrily colliding with the
name of other software I don't personally use.
# As gman, but format for email.
mailman () {
local cmd=
case "$1" in
(-*)
opts="$opts $1"
shift
;;
esac
set -- $(man -w "$@")
cmd=$(zcat --force "$@" | \
grog -Tutf8 -b -ww -P -cbou -rU0 -rLL=72n -rHY=0 -dAD=l \
$opts)
zcat --force "$@" | $cmd | less
}
There are many conveniences packed into that function. I'm happy to
elaborate further; follow-ups might be better sited on the groff list
than bug-bash.
Regards,
Branden
[1] ...such as those accursed with GMail, which has proudly refused to
support an option for rendering emails in monospace for 20+ years,
because everyone at Google is smarter than you
signature.asc
Description: PGP signature