jeff1@stretch.MUN.EDU (Jeff Sparkes) (09/14/89)
bash-1.03 on a sun4 - sunos4 I've run into two problems with using ! in non-history mode. The first is that history expansion takes place even when ! is in quotes, either single or double. The second occurs when I have a filename containing !. If I escape the !, ~ expansion no longer occurs. $ ls xx xx not found $ echo "!ls" ls": Event not found. $ ls ~/lisp/pp.el /users/cs/staff/jeff1/lisp/pp.el $ echo ~/lisp/!myinit.el myinit.el: Event not found. $ echo ~/lisp/\!myinit.el ~/lisp/!myinit.el -- Jeff Sparkes jeff1@garfield.mun.edu || uunet!garfield!jeff1
bfox@AUREL.CALTECH.EDU (Brian Fox) (09/16/89)
Posted-Date: Fri, 15 Sep 89 09:10:13 NDT From: Jeff Sparkes <elroy!ames!cs.utexas.edu!stretch.cs.mun.edu!jeff1@csvax.caltech.edu> Date: Fri, 15 Sep 89 09:10:13 NDT Rob McMahon writes: > In article <429@stretch.MUN.EDU> you write: > >bash-1.03 on a sun4 - sunos4 > > > >The first is that history expansion takes place even when ! is in quotes, > >either single or double. ... > >$ echo "!ls" > >ls": Event not found. > > This is a feature, and the same as csh. It can be useful in things like > > echo "!$" > However, notice that it says ls" not found. The quote stripping is not done correctly. Compared to what? Do you have an example of history expansion that works "correctly"? History expansion is purely textual excepting the cases of counting arguments to the last command. In that case, the line is split into separate words in the same fashion as the shell, and that includes quoted strings. In the case of searching for a string with `!string' quoting is unrelated. However, I concede that the above example stresses the inadequacies of !-style history expansion in general. Perhaps a special case could be made for just this circumstance. Brian Fox
jeff1@stretch.cs.mun.edu (Jeff Sparkes) (09/16/89)
Rob McMahon writes: > In article <429@stretch.MUN.EDU> you write: > >bash-1.03 on a sun4 - sunos4 > > > >The first is that history expansion takes place even when ! is in quotes, > >either single or double. ... > >$ echo "!ls" > >ls": Event not found. > > This is a feature, and the same as csh. It can be useful in things like > > echo "!$" > However, notice that it says ls" not found. The quote stripping is not done correctly.
jeff1@garfield.mun.edu (Jeff Sparkes) (09/17/89)
In article <8909151808.AA26910@aurel.caltech.edu> bfox@AUREL.CALTECH.EDU (Brian Fox) writes: Path: stretch!garfield!uunet!ginosko!gem.mps.ohio-state.edu!tut.cis.ohio-state.edu!AUREL.CALTECH.EDU!bfox From: bfox@AUREL.CALTECH.EDU (Brian Fox) Newsgroups: gnu.bash.bug Date: 15 Sep 89 18:08:35 GMT References: <89Sep15.114226ndt.65635@stretch.cs.mun.edu> Sender: daemon@tut.cis.ohio-state.edu Reply-To: bfox@aurel.caltech.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 36 Posted-Date: Fri, 15 Sep 89 09:10:13 NDT From: Jeff Sparkes <elroy!ames!cs.utexas.edu!stretch.cs.mun.edu!jeff1@csvax.caltech.edu> Date: Fri, 15 Sep 89 09:10:13 NDT Rob McMahon writes: > In article <429@stretch.MUN.EDU> you write: > >bash-1.03 on a sun4 - sunos4 > > > >The first is that history expansion takes place even when ! is in quotes, > >either single or double. ... > >$ echo "!ls" > >ls": Event not found. > > This is a feature, and the same as csh. It can be useful in things like > > echo "!$" > However, notice that it says ls" not found. The quote stripping is not done correctly. Compared to what? Do you have an example of history expansion that works "correctly"? In the case of searching for a string with `!string' quoting is unrelated. However, I concede that the above example stresses the inadequacies of !-style history expansion in general. Perhaps a special case could be made for just this circumstance. Compared to the csh example that Rob mailed me. Csh stripped the quotes. Maybe it is better to do ! expansion on whitespaced words, much the same a tilde expansion. Instead of passing the entire line off to history, just pass the "proper" word. Programs other than bash can choose to hand entire lines off to history. Script started on Sun Sep 17 10:02:34 1989 -docboy- echo ~ /users/cs/staff/jeff1 -docboy- echo "~" ~ -docboy- exit script done on Sun Sep 17 10:02:41 1989 -- Jeff Sparkes jeff1@garfield.mun.edu || uunet!garfield!jeff1
bfox@AUREL.CALTECH.EDU (Brian Fox) (09/17/89)
Date: 17 Sep 89 09:04:06 GMT From: garfield!stretch!jeff1@uunet.uu.net (Jeff Sparkes) In article <8909151808.AA26910@aurel.caltech.edu> bfox@AUREL.CALTECH.EDU (Brian Fox) writes: From: bfox@AUREL.CALTECH.EDU (Brian Fox) Date: 15 Sep 89 18:08:35 GMT From: Jeff Sparkes <elroy!ames!cs.utexas.edu!stretch.cs.mun.edu!jeff1@csvax.caltech.edu> Date: Fri, 15 Sep 89 09:10:13 NDT Rob McMahon writes: > >$ echo "!ls" > >ls": Event not found. > The quote stripping is not done correctly. Compared to what? Do you have an example of history expansion that works "correctly"? Compared to the csh example that Rob mailed me. Where is that example? Here is /bin/csh, SunOs 4.0, Sun3: bfox@aurel$ /bin/csh bfox@aurel%ls foomar ls: foomar: No such file or directory bfox@aurel%echo "!ls" ls": Event not found. Csh stripped the quotes. No it didn't. And then, much to my confusion, you include an example of tilde expansion, demonstrating that Csh does not expand tildes within words: only where the tilde begins the word. What relevance does this have to my question about history expansion? Script started on Sun Sep 17 10:02:34 1989 -docboy- echo ~ /users/cs/staff/jeff1 -docboy- echo "~" ~ -docboy- exit script done on Sun Sep 17 10:02:41 1989 Brian Fox PS: I hacked history expansion do expand history references inside matched quotes, using the close quote as a delimiter, since there is no way to do that particular and useful expansion that I know of in Csh history expansion. That is to say: echo "!ls" expands to echo "ls foomar" I don't know of a way to do this with Csh. Brian
maart@cs.vu.nl (Maarten Litmaath) (09/19/89)
bfox@AUREL.CALTECH.EDU (Brian Fox) writes:
\... echo "!ls"
\
\ expands to
\
\ echo "ls foomar"
\
\I don't know of a way to do this with Csh.
% echo "!{ls}"
echo "ls foomar"
ls foomar
%
--
creat(2) shouldn't have been create(2): |Maarten Litmaath @ VU Amsterdam:
it shouldn't have existed at all. |maart@cs.vu.nl, mcvax!botter!maart