diff options
author | Jacob Bachmeyer <jcb62281@gmail.com> | 2018-12-20 21:24:35 +1100 |
---|---|---|
committer | Ben Elliston <bje@gnu.org> | 2018-12-20 21:24:35 +1100 |
commit | 2f6e46b9820647476ddd568e14d76661abb4f493 (patch) | |
tree | 39dbd80189617ad46ecabcbc2fee82a59d3e529d /commands | |
parent | 80d14caf5d1b26233bb25431243fdfe38cd3f92a (diff) |
* Makefile.am (EXTRA_DIST): Add "dejagnu" launcher script and
contents of $(commands_DATA).
(bin_SCRIPTS): Add "dejagnu" launcher script.
(commandsdir): Installation directory for "dejagnu" subcommands is
$(pkgdatadir)/commands.
(commands_DATA): New, contains "commands/help.sh" as initial item.
(TESTSUITE_FILES): Add testsuite for same.
(DEJATOOL): Add "launcher" to list of tools to test.
(dist_man_MANS): Add man pages for "dejagnu" and "dejagnu help".
* doc/dejagnu.texi (Running other DejaGnu commands): New chapter.
(Invoking dejagnu): New node for dejagnu(1) launcher script.
(Invoking dejagnu help): New node.
* doc/dejagnu.1: New man page.
* doc/dejagnu-help.1: New man page.
* dejagnu: New script.
* commands/help.sh: New dejagnu subcommand for reading manpages.
* testsuite/launcher.all/command.exp: New file.
* testsuite/launcher.all/command/commands/bar-baz.awk: New file.
* testsuite/launcher.all/command/commands/bar.awk: New file.
* testsuite/launcher.all/command/commands/bar.sh: New file.
* testsuite/launcher.all/command/commands/baz-quux.gawk: New file.
* testsuite/launcher.all/command/commands/foo.sh: New file.
* testsuite/launcher.all/command/commands/foo.tcl: New file.
* testsuite/launcher.all/help.exp: New file.
* testsuite/launcher.all/interp.exp: New file.
* testsuite/launcher.all/verbose.exp: New file.
* testsuite/lib/launcher.exp: New file.
Signed-off-by: Ben Elliston <bje@gnu.org>
Diffstat (limited to 'commands')
-rw-r--r-- | commands/help.sh | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/commands/help.sh b/commands/help.sh new file mode 100644 index 0000000..7da4d5f --- /dev/null +++ b/commands/help.sh @@ -0,0 +1,78 @@ +#!/bin/sh +# help.sh -- "dejagnu help" command +# +# Copyright (C) 2018 Free Software Foundation, Inc. +# +# This file is part of DejaGnu. +# +# DejaGnu 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 3 of the License, or +# (at your option) any later version. +# +# DejaGnu 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. +# +# You should have received a copy of the GNU General Public License +# along with DejaGnu; if not, write to the Free Software Foundation, +# Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. + +# ##help +# #Usage: dejagnu help [options...] <command> +# # --verbose, -v Emit additional messages +# # --path, -w Passed to man(1) +# # -W Passed to man(1) +# ##end + +# This script was written by Jacob Bachmeyer. + +args= +command=dejagnu +verbose=0 +for a in "$@"; do + case $a in + -v|--v|-verb*|--verb*) verbose=$((verbose + 1)) ;; + -w|-W|--path) args="${args} ${a}" ;; + -*) echo Unrecognized option "\"$a\"" ;; + *) command="${command}-${a}" ;; + esac +done + +if expr "$verbose" \> 0 > /dev/null ; then + echo Verbose level is $verbose +fi + +## Get the location of this script and check for nearby "doc" dir. +commdir="$(echo "$0" | sed -e 's@/[^/]*$@@')" +docdir="$(echo "$commdir" | sed -e 's@/[^/]*$@@')/doc" + +if expr "$verbose" \> 0 > /dev/null ; then + echo Running from "$commdir" + if expr "$verbose" \> 1 > /dev/null ; then + echo Probing "$docdir" + fi +fi + +if test -d "$docdir"; then + if expr "$verbose" \> 1 > /dev/null ; then + echo Probing "${docdir}/${command}.1" + fi + if test -r "${docdir}/${command}.1" ; then + command="${docdir}/${command}.1" + fi +fi + +# Word splitting on the "args" variable is intended. +# Globbing is not, but ensure that verbose output will show the problem. + +if expr "$verbose" \> 0 > /dev/null ; then + #shellcheck disable=SC2086 + echo Forwarding to man $args "\"$command\"" +fi + +#shellcheck disable=SC2086 +exec man $args "$command" + +#EOF |