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 <2624>; Wed, 1 Jul 1992 09:27:56 -0400 Via: uk.ac.newcastle; Wed, 1 Jul 1992 14:27:01 +0100 Received: from ncl.bygate (bygate.ncl.ac.uk) by ncl.ac.uk; Wed, 1 Jul 1992 13:52:50 +0100 From: Gerry.Tomlinson@newcastle.ac.uk Message-Id: Subject: Re: -s flag To: rc@hawkwind.utcs.toronto.edu Date: Wed, 1 Jul 1992 08:52:48 -0400 In-Reply-To: <9206301529.AA11747@utopia.adobe.com>; from "haahr@com.adobe" at Jun 30, 92 4:42 pm X-Mailer: ELM [version 2.3 PL11] > > > It's a lot better to fix Jove than to 'fix' rc. You could do this like > > vi/ex does it. If I execute a subshell command in vi, then any % is > > replaced by the current filename, ie > > :!mv % %.bak > > would be expanded to > > :!mv foo foo.bak > > etc. This is a lot better than hacking a kludge into rc for the sake of > > one editor. > > i disagree vehemently. shell variable subsitution is a much better defined > mechanism than vi's subtituting for %. (e.g., how do you quote %? what if > you invoked vi without a filename?) in general, i take issue with any > program blindly editing input that the user has typed for another program, > even if that other program is a shell. > > now, one could make the argument that the file should be stored in an > environment variable, e.g. $file, and if every editor were coerced to > use rc's notion of control-a separated lists, that would even work for > multiple files. but $n is a logical place to put the file names, and > has no other conventional meaning for subshells invoked from editors. > I've been thinking how to reference filenames from shell escapes in my X file display program xp (export.lcs.mit.edu:contrib/xp-1.1.tar.Z). I originally adopted the vi % mechanism, simply using system or popen to execute the command after expanding any %'s, however I was never very happy with this 'cos of the quoting problem & the lack of generalisation. My development version does its own "system" thereby 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. Until this discussion started I wasn't even aware of the -s option. When did it first appear? I have a V8 manual to hand and it's in there - does anyone know if it's in Tom Duff's rc? Gerry. Gerry.Tomlinson@newcastle.ac.uk Computing Laboratory, The University, Newcastle upon Tyne, UK, NE1 7RU Tel: +44 091 222 8139