[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[groff] 19/45: [nroff]: Emit usage message on usage errors.
From: |
G. Branden Robinson |
Subject: |
[groff] 19/45: [nroff]: Emit usage message on usage errors. |
Date: |
Thu, 20 Jan 2022 10:17:51 -0500 (EST) |
gbranden pushed a commit to branch master
in repository groff.
commit 5fb4065a11e9d2b6a2dbeb9a4ab19f857bb0f13b
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Sun Jan 16 16:48:47 2022 +1100
[nroff]: Emit usage message on usage errors.
* src/roff/nroff/nroff.sh: Store the usage message in a shell variable
instead of a here document, and sling it to the standard output or
standard error streams, as appropriate.
---
ChangeLog | 8 ++++++++
src/roff/nroff/nroff.sh | 16 ++++++++--------
2 files changed, 16 insertions(+), 8 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 88d79b8f..71920676 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2022-01-16 G. Branden Robinson <g.branden.robinson@gmail.com>
+
+ [nroff]: Emit usage message on usage errors.
+
+ * src/roff/nroff/nroff.sh: Store the usage message in a shell
+ variable instead of a here document, and sling it to the
+ standard output or standard error streams, as appropriate.
+
2022-01-16 G. Branden Robinson <g.branden.robinson@gmail.com>
[grohtml,groff,nroff,troff]: Tweak usage message.
diff --git a/src/roff/nroff/nroff.sh b/src/roff/nroff/nroff.sh
index 9de77e7f..0b21cbad 100644
--- a/src/roff/nroff/nroff.sh
+++ b/src/roff/nroff/nroff.sh
@@ -28,6 +28,11 @@ opts=
dry_run=
is_option_argument_pending=
+usage="usage: $prog [-bcCEhikpRStUVz] [-dCS] [-dNAME=STRING] [-Karg]\
+ [-mNAME] [-Mdir] [-nNUM] [-oLIST] [-Parg] [-rCN] [-rREG=EXPR] [-Tdev]\
+ [-wNAME] [-Wname] [file] ...
+usage: $prog {--help | -v | --version}"
+
for arg
do
if [ -n "$is_option_argument_pending" ]
@@ -67,12 +72,7 @@ do
echo "GNU nroff (groff) version @VERSION@"
opts="$opts $arg" ;;
--help)
- cat <<EOF
-usage: $prog [-bcCEhikpRStUVz] [-dCS] [-dNAME=STRING] [-Karg] [-mNAME]\
- [-Mdir] [-nNUM] [-oLIST] [-Parg] [-rCN] [-rREG=EXPR] [-Tdev] [-wNAME]\
- [-Wname] [file] ...
-usage: $prog {--help | -v | --version}
-EOF
+ echo "$usage"
exit 0 ;;
--)
shift
@@ -80,8 +80,8 @@ EOF
-)
break ;;
-*)
- echo "$prog: usage error: invalid option '$arg';" \
- " see '$prog --help'" >&2
+ echo "$prog: usage error: invalid option '$arg'" >&2
+ echo "$usage" >&2
exit 2 ;;
*)
break ;;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [groff] 19/45: [nroff]: Emit usage message on usage errors.,
G. Branden Robinson <=