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

Re: append to history entry?

On 27/12/16 10:04 PM, Bart Schaefer wrote:
The backslash stuff is borrowed conceptually from C (\t for tab, etc.).
Having that same paradigm applied at multiple levels of processing stems
from the language being interpreted rather than compiled.
I think what I'm not really getting is the multiple level thing. When I get that, maybe difficulties
will melt away.  Of course the backslash is special, hasta be.

The point is that this isn't "natural," because what you asked for isn't
No?  It seems simple enough and the ' : ' command seems tailor made for it.
  but for the
sake of everyone else who's going to see this and copy-paste, it
may be worth forestopping any future problems.

Of course! It's the gotchas that drive me crazy. Un-robust code is alpha code. I guess that's one of these cultural things -- for me the idea that something more or less works most of the time, but never on Thursday, just doesn't cut it.
No, I'll never have a backslash in my $HOST but that's irrelevant because
it hasta be proof against that possibility. I agree with you absolutely. $HOST
is an unformated literal string and should be seen that way every time.

You can't get away from thinking about what you mean.

Indeed not. The difficulty is that what I mean and what zsh thinks I mean ain't the same.

I keep lusting after 'history'. Sheesh, what I want is already there, zsh already knows how to preserve the literal keystrokes that you typed into history, I just can't get at it. If I could just intercept the command as it goes into history -- but with each command knowing what belongs to itself when there are semicolons -- I'd have everything I want:

$ com1 "\'"{(g+)}()\(\t | @$%^>> /dev/the-void < ; com2 "\t"; echo "don't try this at home"

... now hit the up arrow and what I get back is exactly what I typed. So why can't we have:

   function com1 ()
   echo "Here's exactly what you typed, absolutely unmolested, when you
   invoked this command:\n

   $ com1 "\'"{(g+)}()\(\t | @$%^>> /dev/the-void <

   Here's exactly what you typed, absolutely unmolested, when you
   invoked this command:
   com1 "\'"{(g+)}()\(\t | @$%^>> /dev/the-void <


Somewhere, in the deepest bowels of the parser, the literal string exists just before it is sent to history. If I could just grab it somehow ...

Don't let me bother you too much Bart, we've been over this, and it seems it can't be done. In practical terms what you've shown me works perfectly.

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