Thank you so much for the quick responses. My wrapper was already
in place last night and so far I have not received any complaint
from the users. I apologize, though, for not searching through the
csh man page for more info.
My special thank you goes to the following very helpful people:
Ken Stoddart (kendall.stoddart@harris.com)
Barry Margolin (barmar@bbnplanet.com)
Matus Uhlar (uhlar@ccnews.ke.sanet.sk)
Kevin Sheehan (Consulting Poster Child)
Danny Johnson
Eric Peterson (eric@xylan.com)
Mark S. Anderson (manderso@mitre.org)
Tim Evans (tkevans@eplrx7.es.dupont.com)
Vahsen Rob (vahsenr@ce.philips.nl)
Peter Hesse (hessep@gb.swissbank.com)
and others whom I may have missed.
============================================================================
Original question:
I want to write a wrapper for PV Wave instead of putting the line
"source /h/pvi/wave/bin/wvstart" in our global .cshrc file. The reason
for this is that /h/pvi is automounted from the server and sourcing a
file in an automounted file system generates lots of NFS activities.
I have a sample wrapper for rs1 which resides in /usr/local/bin--this
directory is set up in our search path:
#!/bin/csh -f
onintr -
setenv ...
...
/h/rs1/bin/rs1 $*:q
I wonder what ":q" does in the last line. Does it "Q"uit from
/usr/local/bin/rs1 or may be it puts /h/rs1/bin/rs1 in the background
(like &)?
My proposed Wave wrapper looks like this (but I'd like to start the
wave program in the background):
/usr/local/bin/wave:
onintr -
source /h/pvi/wave/bin/wvstart
/h/pvi/wave/bin/wave $*:q
============================================================================
Answer:
The ':q' /h/rs1/bin/rs1 $*:q is a C-shell event modifier. The '$*'
passes all the original command-line arguments and the ':q' modifier
quotes the '$*' values preventing C-shell from making any further
substitutions.
Barry Margolin pointed out that "If you want to suppress the [pid] message
that [is generated by the background command], wrap the line in parentheses,
e.g., (/h/pvi/wave/bin/wave $*:q &)"
Eric Peterson alerted me on the "onintr -" which will ignore all interrupts
so I dropped this line.
Kevin Sheehan, and a few others, suggested that I should use the Bourne
shell instead, and his recommendations are:
1) use /bin/sh - it is much smaller/faster
2) if there is no cleanup done afterwards, use exec - no reason for
a shell process to hang around - and several for it to go.
3) /bin/sh has /etc/profile - so you can have that global - you can
also make the wrapper a built-in function, which is very fast
and cheap.
I combined most of your suggestions and is using the following "wave"
wrapper. Will use the Bourne shell on the Solaris systems.
#!/bin/csh -f
source /h/pvi/wave/bin/wvsetup
exec /h/pvi/wave/bin/`basename $0` $*:q
============================================================================
Portion of csh man page that I received:
Variable substitution:
The modifiers :e, :h, :q, :r, :t, and :x can be applied (see
History Substitution), as can :gh, :gt, and :gr. If {}
(braces) are used, then the modifiers must appear within the
braces. The current implementation allows only one such
modifier per expansion.
HIstory substitution:
Word Designators
A :' (colon) separates the event specification from the
word designator.
Modifiers
After the optional word designator, you can add a sequence
of one or more of the following modifiers, each preceded by
a :.
h Remove a trailing pathname component, leaving the
head.
r Remove a trailing suffix of the form .xxx', leav-
ing the basename.
e Remove all but the suffix.
s/l/r[/]
Substitute r for l.
t Remove all leading pathname components, leaving
the tail.
& Repeat the previous substitution.
g Apply the change to the first occurrence of a
match in each word, by prefixing the above (for
example, g&).
p Print the new command but do not execute it.
q Quote the substituted words, escaping further sub-
stitutions.
x Like q, but break into words at each space charac-
ter, tab or newline.
Unless preceded by a g, the modification is applied only to
the first string that matches l; an error results if no
string matches.
This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:10:51 CDT