Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: quoting of !'s in print -s: not!



> Somebody pointed this out to me a short while ago and I ought to
> report it:  print -s doesn't quote bangs correctly (indeed at all).
> 
> % print -s echo \!hello\!
> <up-arrow>
> % echo !hello!
> zsh: event not found: hello!
> 
> I suspect if anybody is going to alter this it will be Zoltan.  I
> don't now how easy it is.

It is not too easy.  One solution is to use doespandhist() with !"
prepended to the string we are adding to the history (the lexer is
unavoidable here since only unquoted bangs should be quoted and '!'
shouldn't).  For that we have to save/restore several zle variables to
avoid surprises when print is called while zle is active.  I think it is
not really a bug.  What happens is the given arguments are added to the
history unchanged.  Quoting may be undesirable sometions.  E.g. single ! or
!= operators look better if they are left unquoted.

Zoltan




Messages sorted by: Reverse Date, Date, Thread, Author