This bug is fixed in recent Ubuntu releases by using
command_not_found_handler() and might be closed.
Anyway, I need a place to dump old useless code I presumably never need
again (in case I'm wrong and I'll find a use case for this) ...
Actually, according to the POSIX standard and zsh's implementation, exec
returns 127 it the command is not found at all. and 126 if a file matching the
command's name w/o executable bit set if found in $PATH, therefore the correct
fix for this issue would be (if it wouldn't have been fixed by using
command_not_found_handler already), to check if $? is 126 or 127.
An untested example fix (that also fixes other things), based on the
version still in Debian, is pasted below (warning: the sequence >&-
should not be used for anything except shell builtins or commands you
wrote yourself):
[[ -x /usr/share/command-not-found/command-not-found ]] || return 0
function cnf_preexec() {
typeset -g cnf_command="${1%% *}"
}
function cnf_precmd() {
case $? in (126|127)
if [[ -n "${cnf_command-}" && -x
/usr/share/command-not-found/command-not-found ]]
then
whence -- "$cnf_command" >&- ||
/usr/bin/python /usr/share/command-not-found/command-not-found --
"$cnf_command"
unset cnf_command
fi
;;
esac
}
typeset -ga preexec_functions
typeset -ga precmd_functions
preexec_functions+=cnf_preexec
precmd_functions+=cnf_precmd
** Changed in: command-not-found (Ubuntu)
Status: New => Fix Released
--
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/841221
Title:
In zsh command not found triggers upon any subshell exit code != 0
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/command-not-found/+bug/841221/+subscriptions
--
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs