[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[groff] 25/30: [neqn]: Recognize `-h`, `--help` options.
From: |
G. Branden Robinson |
Subject: |
[groff] 25/30: [neqn]: Recognize `-h`, `--help` options. |
Date: |
Sun, 22 Dec 2024 19:39:20 -0500 (EST) |
gbranden pushed a commit to branch master
in repository groff.
commit 2bc287d9a4e41ae55f0bcc3443072eba6cfdad93
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Sat Dec 21 19:28:42 2024 -0600
[neqn]: Recognize `-h`, `--help` options.
* src/preproc/eqn/neqn.sh: Handle `-h` and `--help` options: display a
usage message to the standard output and exit with a successful
status.
Also annotate oddities in shell syntax.
Also work around Solaris 10 /bin/sh brain damage.
Also add editor aid comments.
---
ChangeLog | 6 +++++
src/preproc/eqn/neqn.sh | 59 +++++++++++++++++++++++++++++++++++++++++--------
2 files changed, 56 insertions(+), 9 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index eadd68e15..84a4a7570 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2024-12-21 G. Branden Robinson <g.branden.robinson@gmail.com>
+
+ * src/preproc/eqn/neqn.sh: Handle `-h` and `--help` options:
+ display a usage message to the standard output and exit with a
+ successful status.
+
2024-12-21 G. Branden Robinson <g.branden.robinson@gmail.com>
* src/include/lf.h: Include "stringclass.h" header file, since
diff --git a/src/preproc/eqn/neqn.sh b/src/preproc/eqn/neqn.sh
index 8a094d437..f72a1b46b 100644
--- a/src/preproc/eqn/neqn.sh
+++ b/src/preproc/eqn/neqn.sh
@@ -1,26 +1,67 @@
#!/bin/sh
+#
# Copyright (C) 2014-2024 Free Software Foundation, Inc.
#
# This file is part of groff.
-#
+#
# groff is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free
# Software Foundation, either version 2 of the License (GPL2).
-#
-# groff is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or
+#
+# groff is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
-#
+#
# The GPL2 license text is available in the internet at
# <http://www.gnu.org/licenses/gpl-2.0.txt>.
-# Provision of this shell script should not be taken to imply that use of
-# GNU eqn with groff -Tascii|-Tlatin1|-Tutf8 is supported.
+# Provision of this shell script should not be taken to imply that use
+# of GNU eqn with groff -Tascii|-Tlatin1|-Tutf8 is supported.
+
+# Screen for shells non-conforming with POSIX Issue 4 (1994).
+badshell=yes
+# Solaris 10 /bin/sh is so wretched that it not only doesn't support
+# standard parameter expansion, but it also writes diagnostic messages
+# to the standard output instead of standard error.
+if [ -n "$SHELL" ]
+then
+ "$SHELL" -c 'prog=${0##*/}' >/dev/null 2>&1 && badshell=
+fi
+
+if [ -n "$badshell" ]
+then
+ prog=`basename $0`
+else
+ prog=${0##*/}
+fi
@GROFF_BIN_PATH_SETUP@
PATH="$GROFF_RUNTIME$PATH"
export PATH
-exec @g@eqn -Tascii ${1+"$@"}
-# eof
+for arg
+do
+ case "$arg" in
+ -h|--help)
+ cat <<EOF
+usage: $prog [eqn-option ...] [file ...]
+usage: $prog {-h | --help}
+
+$prog invokes eqn(1) with the '-T ascii' option and any other arguments
+specified. See the neqn(1) manual page.
+EOF
+ exit 0
+ ;;
+ esac
+done
+
+# Note: The construction '${1+"@$"}' preserves the absence of arguments
+# in old shells; see "Shell Substitutions" in the GNU Autoconf manual.
+# We don't want 'neqn' to become 'neqn ... ""' if $# equals zero.
+exec @g@eqn -T ascii ${1+"$@"}
+
+# Local Variables:
+# fill-column: 72
+# End:
+# vim: set autoindent expandtab shiftwidth=2 softtabstop=2 textwidth=72:
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [groff] 25/30: [neqn]: Recognize `-h`, `--help` options.,
G. Branden Robinson <=