gbranden pushed a commit to branch master in repository groff. commit 5015fc1d365caee6235d87939ae5341977526623 Author: G. Branden Robinson <g.branden.robin...@gmail.com> AuthorDate: Sat Aug 2 07:13:57 2025 -0500
[{eqn,grap,pic}2graph]: Improve usage messages. Tell the user what the program is for when issuing message. Compute the name of the program using a technique from groff's "nroff.sh". --- contrib/eqn2graph/eqn2graph.sh | 31 +++++++++++++++++++++++++++++-- contrib/grap2graph/grap2graph.sh | 32 ++++++++++++++++++++++++++++++-- contrib/pic2graph/pic2graph.sh | 34 ++++++++++++++++++++++++++++++++-- 3 files changed, 91 insertions(+), 6 deletions(-) diff --git a/contrib/eqn2graph/eqn2graph.sh b/contrib/eqn2graph/eqn2graph.sh index 059ca50b5..8f6f5c9f7 100644 --- a/contrib/eqn2graph/eqn2graph.sh +++ b/contrib/eqn2graph/eqn2graph.sh @@ -5,6 +5,8 @@ # by Eric S. Raymond <e...@thyrsus.com>, July 2002 # based on a recipe by W. Richard Stevens # +# salves for shell portability agonies by G. Branden Robinson +# # Take an eqn equation on stdin, emit cropped bitmap on stdout. The eqn # markup should *not* be wrapped in .EQ/.EN, this script will do that. # A -format FOO option changes the image output format to any format @@ -28,6 +30,31 @@ # # Thus, we pass everything except -format to convert(1). +# 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 + +usage="usage: $prog [-format output-format] [convert-argument ...] +$prog {-v | --version} +$prog --help + +Read a one-line eqn(1) equation from the standard input and write an +image file, by default in Portable Network Graphics (PNG) format, to the +standard output. See the eqn2graph(1) manual page." + convert_opts="" convert_trim_arg="-trim" format="png" @@ -39,10 +66,10 @@ do format=$2 shift;; -v | --version) - echo "eqn2graph (groff) version @VERSION@" + echo "$prog (groff) version @VERSION@" exit 0;; --help) - echo "usage: eqn2graph [ option ...] < in > out" + echo "$usage" exit 0;; *) convert_opts="$convert_opts $1";; diff --git a/contrib/grap2graph/grap2graph.sh b/contrib/grap2graph/grap2graph.sh index f9628f34c..cda70b1ab 100644 --- a/contrib/grap2graph/grap2graph.sh +++ b/contrib/grap2graph/grap2graph.sh @@ -5,6 +5,8 @@ # by Eric S. Raymond <e...@thyrsus.com>, May 2003 # based on a recipe by W. Richard Stevens # +# salves for shell portability agonies by G. Branden Robinson +# # Take grap description on stdin, emit cropped bitmap on stdout. The # grap markup should *not* be wrapped in .G1/.G2, this script will do # that. A -U option on the command line enables gpic/groff "unsafe" @@ -27,6 +29,32 @@ # # Thus, we pass -U to groff(1), and everything else to convert(1). +# 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 + +usage="usage: $prog [-unsafe] [-format output-format] \ +[convert-argument ...] +$prog {-v | --version} +$prog --help + +Read a grap(1) program from the standard input and write an image file, +by default in Portable Network Graphics (PNG) format, to the standard +output. See the grap2graph(1) manual page." + groff_opts="" convert_opts="" convert_trim_arg="-trim" @@ -41,10 +69,10 @@ do format=$2 shift;; -v | --version) - echo "grap2graph (groff) version @VERSION@" + echo "$prog (groff) version @VERSION@" exit 0;; --help) - echo "usage: grap2graph [ option ...] < in > out" + echo "$usage" exit 0;; *) convert_opts="$convert_opts $1";; diff --git a/contrib/pic2graph/pic2graph.sh b/contrib/pic2graph/pic2graph.sh index fad024697..6edf80002 100644 --- a/contrib/pic2graph/pic2graph.sh +++ b/contrib/pic2graph/pic2graph.sh @@ -5,6 +5,8 @@ # by Eric S. Raymond <e...@thyrsus.com>, July 2002 # based on a recipe by W. Richard Stevens # +# salves for shell portability agonies by G. Branden Robinson +# # Take a pic/eqn diagram on stdin, emit cropped bitmap on stdout. The # pic markup should *not* be wrapped in .PS/.PE, this script will do # that. An -unsafe option on the command line enables gpic/groff @@ -34,6 +36,34 @@ # We don't have complete option coverage on eqn because this is # primarily intended as a pic translator; we can live with eqn defaults. +# 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 + +usage="usage: $prog [-unsafe] [-format output-format] \ +[-eqn delimiters] [convert-argument ...] +$prog {-v | --version} +$prog --help + +Read a pic(1) program from the standard input and write an image file, +by default in Portable Network Graphics (PNG) format, to the standard +output. The program furthermore translates eqn(1) constructs, so it can +be used to generate images of mathematical formulae. See the +pic2graph(1) manual page." + groffpic_opts="" convert_opts="" convert_trim_arg="-trim" @@ -52,10 +82,10 @@ do eqndelim=$2 shift;; -v | --version) - echo "pic2graph (groff) version @VERSION@" + echo "$prog (groff) version @VERSION@" exit 0;; --help) - echo "usage: pic2graph [ option ...] < in > out" + echo "$usage" exit 0;; *) convert_opts="$convert_opts $1";; _______________________________________________ groff-commit mailing list groff-commit@gnu.org https://lists.gnu.org/mailman/listinfo/groff-commit