rc-list - mailing list for the rc(1) shell
 help / color / mirror / Atom feed
From: hugh@mimosa.com ("D. Hugh Redelmeier")
To: Gerry.Tomlinson@newcastle.ac.uk, rc@hawkwind.utcs.toronto.edu
Subject: Re: -s flag
Date: Wed, 1 Jul 1992 17:30:14 -0400	[thread overview]
Message-ID: <9207012130.AA10806@redvax.mimosa.com> (raw)

| 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


             reply	other threads:[~1992-07-01 21:31 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1992-07-01 21:30 "D. Hugh Redelmeier" [this message]
1992-07-02 12:52 ` Gerry.Tomlinson
  -- strict thread matches above, loose matches on Subject: below --
1992-07-02 14:03 Chet Ramey
1992-06-30 15:29 haahr
1992-07-01 12:52 ` Gerry.Tomlinson
1992-07-01 21:14   ` Chris Siebenmann
1992-06-30 15:03 "D. Hugh Redelmeier"
1992-06-30  6:55 "D. Hugh Redelmeier"
1992-06-30  8:26 ` Matthew Farwell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9207012130.AA10806@redvax.mimosa.com \
    --to=hugh@mimosa.com \
    --cc=Gerry.Tomlinson@newcastle.ac.uk \
    --cc=rc@hawkwind.utcs.toronto.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).