Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: append to history entry?
On Dec 28, 9:39am, Ray Andrews wrote:
} Subject: Re: append to history entry?
}
} On 27/12/16 10:04 PM, Bart Schaefer wrote:
} > 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.
As it has ever been in pretty much all programming languages.
} 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
That's where your confusion is. History is *NOT* command history.
It's *command line input* history. History does NOT know what text
belongs to what command, and it's not processed at the same level as
the parser that figures that out. It's involved with the lexer,
which decides how to break things into tokens but does not decide
what those tokens mean. History is thus connected more closely to
the line editor than to the command execution engine.
} Somewhere, in the deepest bowels of the parser, the literal string
} exists just before it is sent to history.
No, that's completely wrong. The literal string is long gone by the
time you get that far down in the parser. When your "com1" function
is called, all the expansions and substitutions have long since been
done and the original text discarded; "setopt xtrace" and look at the
output -- THAT is what exists at the point "com1" runs.
In fact by that point the literal command input is *already in* the
history, unless you've stopped it somehow e.g. histignorespace.
Read up on the "trap" command with the DEBUG pseudo-signal, and the
ZSH_DEBUG_CMD variable, which is the closest thing there is to what
you are imagining.
The zshaddhistory hook is where you get at the literal input string.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author