groff
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Groff] a calling interface for shell scripts in groff


From: Bernd Warken
Subject: Re: [Groff] a calling interface for shell scripts in groff
Date: Sun, 14 Jul 2002 10:10:16 +0200
User-agent: Mutt/1.2.5i

On Sat, Jul 13, 2002 at 11:02:28PM +0200, Werner LEMBERG wrote:
> 
> > Shell scripts run much faster and more compatible with the `ash'
> > shell.  But as `ash' is not available at each system it cannot be
> > provided by the `#! /bin/ash' method.  Are there any ideas about how
> > this could be solved?
> 
> At configure time the existence of ash could be tested (I don't know
> whether this is possible at all).  If in the path, @GROFF_SHELL@ could
> be substituted accordingly.
> 
I found a possibility to solve the shell problem.  Consider the 
following example shell script.  It tests the existence of `ash' and 
if found it is run a second time using ash.  The only external 
configuration needed is the install file position, which can be 
constructed from existing `configure' information.


##############################
#!/bin/bash
#
# t.sh
#
# Run under alternative shells.
#
_THIS='t.sh'
export _THIS;
export _SECOND_RUN;

test_ash()
{
  test "$(ash -c 'echo -n ok' 2>/dev/null)" = 'ok';
}

if test "${_SECOND_RUN}" != 'yes'; then
  # only reached with the run of the script
  if test_ash; then
    _SECOND_RUN='yes';
    exec ash "${_THIS}";
    exit
  fi;
fi;

# this is only reached under the following conditions:
# 1. on the first run of the script when the test for `ash' failed; the
#    actual shell is then `bash'.
# 2. on the second run of the script when the test for `ash' succeeded;
#    the actual shell is then `ash'.

if test "${BASH_VERSION}" != ''; then
  echo 'this is bash' >&2;
else
  echo 'this is ash' >&2;
fi;
echo done >&2

#########################

Bernd Warken


reply via email to

[Prev in Thread] Current Thread [Next in Thread]