Since I posted my summary yesterday, Vasu Vuppala sent me more
useful information on writing wrapper scripts in the ksh that
I would like to pass on. Here is another summary with the
added info:
Original question:
=================
I have a line in my csh wrapper to start my program:
exec /usr/mri/master/bin/`basename $0` $*:q
How do I convert the above line to Korn shell and Bourne shell to pass
all the parameters to the command? One of my actual commands to call
xsh is:
xsh -t mri02
Solutions:
=========
Both of the following lines work (in ksh and sh):
exec /usr/mri/master/bin/`basename $0` "$@"
exec /usr/mri/master/bin/`basename $0` "${@:-}"
Added info from Vasu:
====================
as you know, using `basename $0` invokes another process, which is costly.
ksh provides parameter substitution constructs to do the equivalent. so a
better
way in ksh would be
exec /usr/mri/master/bin/"${0##*/}" "${@:-}"
${X##*/} represents,
$X with its longest prefix matching the pattern '*/' deleted
This is just a parameter substitution done inside ksh and does not invoke any
other process.
Vicky Lau
This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:11:49 CDT