Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Handling Command Not Found
- X-seq: zsh-users 14614
- From: Peter Stephenson <pws@xxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: Re: Handling Command Not Found
- Date: Fri, 27 Nov 2009 14:06:28 +0000
- In-reply-to: <ad024e3c0911262212n732a18ebt2a66a3ad77331402@xxxxxxxxxxxxxx>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- Organization: CSR
- References: <ad024e3c0911262212n732a18ebt2a66a3ad77331402@xxxxxxxxxxxxxx>
On Fri, 27 Nov 2009 00:12:04 -0600
Adam Walters <ajwalters@xxxxxxxxx> wrote:
> I was wondering if zsh had a way to handle command not found by running a
> function? Ideally, I would like to pipe the input of a command not into a
> ruby script. Is there any way to accomplish this in zsh?
You can define a command_not_found_handler function in recent versions
of the shell (4.3.something-or-other). See the zshmisc manual page
under COMMAND EXECUTION.
For example,
command_not_found_handler() {
if [[ $1 = foo ]]; then
print "I handled foo"
return 0
else
return 127
fi
}
% foo
I handled foo
% print $?
0
% zsh: command not found: not_foo
% print $?
127
--
Peter Stephenson <pws@xxxxxxx> Software Engineer
Tel: +44 (0)1223 692070 Cambridge Silicon Radio Limited
Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK
Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom
Messages sorted by:
Reverse Date,
Date,
Thread,
Author