Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: trapped in bash
- X-seq: zsh-users 22236
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: Re: trapped in bash
- Date: Sun, 18 Dec 2016 18:30:56 -0800
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=from:message-id:date:in-reply-to:comments:references:to:subject :mime-version; bh=oRBtF26ZLvEHhn4WTAD52TMZ157HVmCgIKXUmuoqc24=; b=f3u6zaIuuNS360P8FYGArwJQErpXJWRmsZUGNh9LK3Yb1F4yf1XjGkEz+0BR/Q8W0R yyFHM6kgvfZmvEKqW/DYzZT++XqxZY0X6QpNA4Z91kPum2K1AAq/JLqT32fDs78JGLq/ ynHX17B2/P9G00W3+LR02tMTwJ6YVr8LBGA6kbzUL/x75+klY74fC3m/yBp6joz40fqP iT4WjW5m+o/gzqRMX8FE+NoN7LZkuO9X1AjxJtxUGuSW5Sag1zdKOmeo1XDGHRDwQmVJ /eXBs4BB8gZioTBqpn+9A7JIbo6ToRSD0+dis0qfHVd2DYlGYuriVYgf0ryZB5M55ugf trXA==
- In-reply-to: <20161219003219.GA21509@fujitsu.shahaf.local2>
- 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
- References: <58540944.3030706@eastlink.ca> <20161216215117.GF2023@pug.qqx.org> <58546D36.5050908@eastlink.ca> <161216150556.ZM4016@torch.brasslantern.com> <58559FC0.3080501@eastlink.ca> <161217124354.ZM7815@torch.brasslantern.com> <5855BEF2.6090208__18199.534857604$1482015164$gmane$org@eastlink.ca> <20161218150628.GB9158@fujitsu.shahaf.local2> <5856B133.9010602@eastlink.ca> <20161219003219.GA21509@fujitsu.shahaf.local2>
On Dec 19, 12:32am, Daniel Shahaf wrote:
}
} I suppose you could write a command_not_found_handler() function that
} tried to reverse engineer _why_ the command wasn't found - with the
} obvious limitations, e.g., race conditions between the library's
} execution and the handler's.
I don't think there can be a race here because the handler won't be
invoked if the execve() hasn't already failed.
Something like this:
command_not_found_handler () {
local attempt="$1"
if [[ "$1" != /* && ( -o pathdirs || "$1
" != */* ) ]]
then
emulate zsh -c 'attempt=$^path/$1(N[1])'
fi
if [[ -f $attempt ]]
then
local hashbang
read -u 0 -k 2 hashbang < "$attempt"
case "$hashbang" in
('#!') print -u2 -- $1\: bad '#!' interpreter ;;
(*) print -u2 failed to load $1 ;;
esac
else
print -u2 -- $1\: no such file in \$PATH
fi
return 127
}
--
Barton E. Schaefer
Messages sorted by:
Reverse Date,
Date,
Thread,
Author