From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from sun2.nsfnet-relay.ac.uk ([128.86.8.45]) by hawkwind.utcs.toronto.edu with SMTP id <2664>; Thu, 2 Jul 1992 08:53:00 -0400 Via: uk.ac.newcastle; Thu, 2 Jul 1992 13:52:25 +0100 Received: from ncl.bygate (bygate.ncl.ac.uk) by ncl.ac.uk; Thu, 2 Jul 1992 13:52:22 +0100 From: Gerry.Tomlinson@newcastle.ac.uk Message-Id: Subject: Re: -s flag To: rc@hawkwind.utcs.toronto.edu Date: Thu, 2 Jul 1992 08:52:21 -0400 In-Reply-To: <9207012130.AA10806@redvax.mimosa.com>; from "D._Hugh_Redelmeier" at Jul 1, 92 10:37 pm X-Mailer: ELM [version 2.3 PL11] > > | 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. > yes, if all shells did the same with -c. > 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. > being an X program I'd make the variable name a resource so you can chose your own, but won't any clash only occur in functions which don't redeclare the variable locally? > Unfortunately, the positional parameters after -c or -s are not > treated the same in different shells (at least under SunOS4.0.3): > and it's different again on bash and I suspect other shells - on On various machines I have access to I find: ; rc -c 'echo $*' one two one two ; ash -c 'echo $*' one two one two ; csh -c 'echo $*' one two one two ; ksh -c 'echo $*' one two one two ; sh -c 'echo $*' one two two ; bash -c 'echo $*' one two ; back to -s, matty@cs.su.OZ.AU mailed me the Plan 9 manual entry for rc: > Invocation > If rc is started with no arguments it reads commands from > standard input. Otherwise its first non-flag argument is > the name of a file from which to read commands (but see -c > below). Subsequent arguments become the initial value of > $*. Rc accepts the following command-line flags. > -c string Commands are read from string. > -s Print out exit status after any command where the > status is non-null. > -e Exit if $status is non-null after executing a > simple command. > -i If -i is present, or rc is given no arguments and > its standard input is a terminal, it runs inter- > actively. Commands are prompted for using > $prompt. > -I Makes sure rc is not run interactively. > -l If -l is given or the first character of argument > zero is -, rc reads commands from > $home/lib/profile, if it exists, before reading > > Page 8 Plan 9 (printed 7/2/92) > > RC(1) RC(1) > > its normal input. > -p A no-op. > -d A no-op. > -v Echo input on file descriptor 2 as it is read. > -x Print each simple command before executing it. > -r Print debugging information (internal form of > commands as they are executed). > > So, at least the version of rc we are using does not use the -s flag in > the manner of recent discussion. You can post this to the rc group if > you feel people would be interested. > > Matty. seems like you can't win :-(, Gerry. Gerry.Tomlinson@newcastle.ac.uk Computing Laboratory, The University, Newcastle upon Tyne, UK, NE1 7RU Tel: +44 091 222 8139