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, see <http://www.gnu.org/licenses/>.
22 # #Usage: dejagnu help [ OPTIONS... ] COMMAND
23 # # --verbose, -v Emit additional messages
24 # # --path, -w Passed to man(1)
25 # # -W Passed to man(1)
28 # shellcheck disable=SC2003
29 # The shellcheck tool complains about use of expr and recommends using
30 # newer shell features instead. Solaris 10 /bin/sh does not support the
31 # newer features, so we must use expr in this script.
33 # shellcheck disable=SC2006
34 # The shellcheck tool complains about the old style backtick command
35 # substitution. Solaris 10 /bin/sh does not support the new style $()
36 # command substitution and the usage of command substitution in this script
37 # is simple enough to work. Most notably, nesting backtick command
38 # substitution is tricky, but we do not do that.
40 # This script was written by Jacob Bachmeyer.
42 # For testing and development
44 if test x
"$1" = x--DGTest
; then
54 -v|
--v|
-verb*|
--verb*) verbose
=`expr $verbose + 1` ;;
55 -w|
-W|
--path) args
="${args} ${a}" ;;
56 -*) echo Unrecognized option
"\"$a\"" ;;
57 *) command="${command}-${a}" ;;
61 if expr "$verbose" \
> 0 > /dev
/null
; then
62 echo Verbose level is
$verbose
65 ## Get the location of this script and check for nearby "doc" dir.
66 commdir
=`echo "$0" | sed -e 's@/[^/]*$@@'`
67 docdir
=`echo "$commdir" | sed -e 's@/[^/]*$@@'`/doc
69 if expr "$verbose" \
> 0 > /dev
/null
; then
70 echo Running from
"$commdir"
71 if expr "$verbose" \
> 1 > /dev
/null
; then
72 echo Probing
"$docdir"
76 if test -d "$docdir"; then
77 if expr "$verbose" \
> 1 > /dev
/null
; then
78 echo Probing
"${docdir}/${command}.1"
80 if test -r "${docdir}/${command}.1" ; then
81 command="${docdir}/${command}.1"
85 # Word splitting on the "args" variable is intended.
86 # Globbing is not, but ensure that verbose output will show the problem.
88 if expr "$verbose" \
> 0 > /dev
/null
; then
89 #shellcheck disable=SC2086
90 echo Forwarding to man
$args "\"$command\""
93 if $in_test_mode ; then
94 echo man
"$args $command"
96 #shellcheck disable=SC2086
97 exec man
$args "$command"