Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: "Fallback" alias/function in zsh
- X-seq: zsh-users 1968
- From: "Bart Schaefer" <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxxxxxxxxxx
- Subject: Re: "Fallback" alias/function in zsh
- Date: Tue, 8 Dec 1998 18:55:01 -0800
- In-reply-to: <19981209011923.40055@xxxxxxxxxxxxxxxxxxxxx>
- References: <19981208220443.A180@xxxxxxxxxxxxxxxxxxxx> <981208155032.ZM7173@xxxxxxxxxxxxxxxxxxxxxxx> <19981209011923.40055@xxxxxxxxxxxxxxxxxxxxx>
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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author