From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16879 invoked from network); 9 Dec 1998 02:58:11 -0000 Received: from math.gatech.edu (list@130.207.146.50) by ns1.primenet.com.au with SMTP; 9 Dec 1998 02:58:11 -0000 Received: (from list@localhost) by math.gatech.edu (8.9.1/8.9.1) id VAA09535; Tue, 8 Dec 1998 21:56:44 -0500 (EST) Resent-Date: Tue, 8 Dec 1998 21:56:10 -0500 (EST) From: "Bart Schaefer" Message-Id: <981208185501.ZM7746@candle.brasslantern.com> Date: Tue, 8 Dec 1998 18:55:01 -0800 In-Reply-To: <19981209011923.40055@athenaeum.demon.co.uk> Comments: In reply to Phil Pennock "Re: "Fallback" alias/function in zsh" (Dec 9, 1:19am) References: <19981208220443.A180@morpheus.demon.co.uk> <981208155032.ZM7173@candle.brasslantern.com> <19981209011923.40055@athenaeum.demon.co.uk> X-Mailer: Z-Mail (4.0b.820 20aug96) To: zsh-users@math.gatech.edu Subject: Re: "Fallback" alias/function in zsh MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Resent-Message-ID: <"vhLMD.0.8K2.ARURs"@math> Resent-From: zsh-users@math.gatech.edu X-Mailing-List: archive/latest/1968 X-Loop: zsh-users@math.gatech.edu X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu On Dec 9, 1:19am, Phil Pennock wrote: } Subject: 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[@]" } > } } } 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 ... Easily enough adjusted: function precmd() { (($?)) && { whence "$command[1]" >& /dev/null || CMD /C "$command[@]" } } -- Bart Schaefer Brass Lantern Enterprises http://www.well.com/user/barts http://www.brasslantern.com