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

Re: preexec hook: possible enhancement?



Bart Schaefer wrote:
> On Sep 5, 12:34pm, Matthew Wozniski wrote:
> }
> } While we're on the topic of using the preexec hook to set the
> } titlebar, I'd like to bounce something off the list and see if 1) it's
> } possible and 2) people would consider it useful.  So, would it be
> } possible and/or useful to have the preexec hook (or some other, new
> } hook) fire once for each pipeline in the current command, rather
> } than just once using the entire current line?
> 
> The TRAPDEBUG function is called at these points in the execution,
> if you "setopt DEBUG_BEFORE_CMD".  However, I don't remember offhand
> whether it's possible to access the command text that is about to be
> executed.  The documentation for TRAPDEBUG is pretty sparse.
> 
> (Also DEBUG_BEFORE_CMD requires a very recent zsh version.)

I doubt if there's much joy there... debug traps are called before/after
every command, including in precmd and preexec, so probably far too
often.  (They're for debugging, right?)  The only argument to a
TRAPDEBUG function is the signal number, which is meaningless in this
case anyway.  The older stuff like this ksh import doesn't tend to be
tightly enough defined to be useful interactively.

The idea of a hook between pipelines is actually rather different from
preexec and precmd; those get run around the time the shell fetches the
line for editing, rather than in the middle of execution.  Running
something after every pipeline would have to dig its mitts into into the
execution tree, which is why Bart suggested debug traps.

It doesn't look like there's a clean way to do this.

-- 
Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/



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