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

Re: "Fallback" alias/function in zsh



Typing away merrily, Bart Schaefer produced the immortal words:
> In 3.1.5, there's the preexec() function, in which you could do something
> like this:
> 
>   function preexec() {
>     command=("$@")
>   }
>   function precmd() {
>     (($?)) && CMD /C "$command[@]"
>   }
[...]
> This will do unusual things when you execute compound commands (separated
> with ; && || etc.) and won't work for backgrounded commands (&) but should
> do what you want for simple commands typed at the prompt.

That seems dangerous.  The problem looks to be 'if path lookup fails'
not 'if path lookup fails or program returns non-zero'; could be fun to
run a grep(1) port and have it run twice if no matches were found ...
-- 
--> Phil Pennock ; GAT d- s+:+ a22 C++(++++) UL++++/I+++/S+++/H+ P++@ L+++
E-@ W(+) N>++ o !K w--- O>+ M V !PS PE Y+ PGP+ t-- 5++ X+ R !tv b++>+++ DI+ D+
G+ e+ h* r y?



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