Ensure that PR42399 regression test produces results
[dejagnu.git] / commands / help.sh
blob1070ece3e44ddf2f6fa9b077526f6a8f11fac414
1 #!/bin/sh
2 # help.sh -- "dejagnu help" command
4 # Copyright (C) 2018, 2021 Free Software Foundation, Inc.
6 # This file is part of DejaGnu.
8 # DejaGnu is free software; you can redistribute it and/or modify it
9 # under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 3 of the License, or
11 # (at your option) any later version.
13 # DejaGnu is distributed in the hope that it will be useful, but
14 # WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 # General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with DejaGnu; if not, write to the Free Software Foundation,
20 # Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
22 # ##help
23 # #Usage: dejagnu help [ OPTIONS... ] COMMAND
24 # # --verbose, -v Emit additional messages
25 # # --path, -w Passed to man(1)
26 # # -W Passed to man(1)
27 # ##end
29 # shellcheck disable=SC2003
30 # The shellcheck tool complains about use of expr and recommends using
31 # newer shell features instead. Solaris 10 /bin/sh does not support the
32 # newer features, so we must use expr in this script.
34 # shellcheck disable=SC2006
35 # The shellcheck tool complains about the old style backtick command
36 # substitution. Solaris 10 /bin/sh does not support the new style $()
37 # command substitution and the usage of command substitution in this script
38 # is simple enough to work. Most notably, nesting backtick command
39 # substitution is tricky, but we do not do that.
41 # This script was written by Jacob Bachmeyer.
43 args=
44 command=dejagnu
45 verbose=0
46 for a in "$@"; do
47 case $a in
48 -v|--v|-verb*|--verb*) verbose=`expr $verbose + 1` ;;
49 -w|-W|--path) args="${args} ${a}" ;;
50 -*) echo Unrecognized option "\"$a\"" ;;
51 *) command="${command}-${a}" ;;
52 esac
53 done
55 if expr "$verbose" \> 0 > /dev/null ; then
56 echo Verbose level is $verbose
59 ## Get the location of this script and check for nearby "doc" dir.
60 commdir=`echo "$0" | sed -e 's@/[^/]*$@@'`
61 docdir=`echo "$commdir" | sed -e 's@/[^/]*$@@'`/doc
63 if expr "$verbose" \> 0 > /dev/null ; then
64 echo Running from "$commdir"
65 if expr "$verbose" \> 1 > /dev/null ; then
66 echo Probing "$docdir"
70 if test -d "$docdir"; then
71 if expr "$verbose" \> 1 > /dev/null ; then
72 echo Probing "${docdir}/${command}.1"
74 if test -r "${docdir}/${command}.1" ; then
75 command="${docdir}/${command}.1"
79 # Word splitting on the "args" variable is intended.
80 # Globbing is not, but ensure that verbose output will show the problem.
82 if expr "$verbose" \> 0 > /dev/null ; then
83 #shellcheck disable=SC2086
84 echo Forwarding to man $args "\"$command\""
87 #shellcheck disable=SC2086
88 exec man $args "$command"
90 #EOF