From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15433 invoked from network); 8 Dec 1998 23:53:38 -0000 Received: from math.gatech.edu (list@130.207.146.50) by ns1.primenet.com.au with SMTP; 8 Dec 1998 23:53:38 -0000 Received: (from list@localhost) by math.gatech.edu (8.9.1/8.9.1) id SAA04857; Tue, 8 Dec 1998 18:52:32 -0500 (EST) Resent-Date: Tue, 8 Dec 1998 18:52:27 -0500 (EST) From: "Bart Schaefer" Message-Id: <981208155032.ZM7173@candle.brasslantern.com> Date: Tue, 8 Dec 1998 15:50:32 -0800 In-Reply-To: <19981208220443.A180@morpheus.demon.co.uk> Comments: In reply to Paul Moore ""Fallback" alias/function in zsh" (Dec 8, 10:04pm) References: <19981208220443.A180@morpheus.demon.co.uk> X-Mailer: Z-Mail Lite (5.0.0 30July97) To: Paul Moore , 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: <"_Rt1x3.0.VB1.wkRRs"@math> Resent-From: zsh-users@math.gatech.edu X-Mailing-List: archive/latest/1966 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 8, 10:04pm, Paul Moore wrote: > Subject: "Fallback" alias/function in zsh > > Is it possible to define a function which gets used whenever zsh's > normal alias/function/builtin/path lookup fails? 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 means, before executing the command, save it in $command; then, after executing it (and just before printing the prompt) if the exit status was nonzero, attempt to execute the command with CMD /C. 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. Of course, 3.1.5 isn't ported to Windows yet ...