From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from yonge.csri.toronto.edu ([128.100.1.2]) by hawkwind.utcs.toronto.edu with SMTP id <2718>; Wed, 1 Jul 1992 17:31:52 -0400 Received: from redvax by yonge.csri.toronto.edu with UUCP id <5046>; Wed, 1 Jul 1992 17:31:29 -0400 Received: by redvax.mimosa.com (4.0/SMI-4.0) id AA10806; Wed, 1 Jul 92 17:30:14 EDT Date: Wed, 1 Jul 1992 17:30:14 -0400 From: hugh@mimosa.com ("D. Hugh Redelmeier") Message-Id: <9207012130.AA10806@redvax.mimosa.com> To: Gerry.Tomlinson@newcastle.ac.uk, rc@hawkwind.utcs.toronto.edu Subject: Re: -s flag | respecting $SHELL so I can use all my rc functions. If instead I execed | $SHELL -s with the command line as stdin, with the filenames as the | arguments, and set the environment variable i to be that of the current | file, then one could reference all files with $*, numbered files with $n, | and the current file with $i, without xp having to touch the user's | input. Much nicer I think. I suspect that you would be better off using -c. It too allows passing parameters to the command. That way you need not fool with stdin. As a matter of taste, I have misgivings about taking over $i. It is a variable name that I frequently use in scripts. That is the beauty of $1 etc.: those names were already reserved for this mechanism. Of course, $current is a bit tiresome to type. Unfortunately, the positional parameters after -c or -s are not treated the same in different shells (at least under SunOS4.0.3): $ sh -c 'echo $*' one two two $ sh -c 'echo $0 $1' one two one two $ csh -c 'echo $*' one two one two $ csh -c 'echo $0 $1' one two No file for $0. $ rc -c 'echo $*' one two one two $ rc -c 'echo $0 $1' one two rc one [This is an old version of rc; it may have changed.] $ sh -si one two $ echo $* one two $ echo $0 $1 sh one $ exit $ csh -si one two redvax% echo $* one two redvax% echo $0 $1 No file for $0. redvax% exit $ rc -si one two rc: illegal option -- s $ rc -i one two one: No such file or directory For portability reasons, I only promise to set $1, and I do so by passing two copies of the string as positional parameters. Hugh Redelmeier hugh@mimosa.com or {utcsri, uunet!attcan, utzoo, scocan}!redvax!hugh When all else fails: hugh@csri.toronto.edu +1 416 482-8253