I've finally decided to take the plunge and try out zsh. Running on a CentOS 7 machine. The only thing I find strangely aggravating is that for some reason each time I enter an unknown command, I get command not found twice:

For example, if I type "fail"

zsh: fail: command not found...
zsh: command not found: fail

I can't for the life of me figure out why this is the case, or find anyone else that seems to have had this problem. Perhaps my Google-fu is not strong enough, but any pointers would be appreciated.

my .zsh is just the basic one so far:


bindkey -e

zstyle :compinstall filename '/home/bmgraves/.zshrc'
autoload -Uz compinit

with bash:

bash: fail: command not found...


fail: Command not found.

print $+functions[command_not_found_handler]

+zsh:2> print 1

zsh -x:

+zsh:7> fail
+command_not_found_handle:1> local 'runcnf=1'
+command_not_found_handle:2> local 'retval=127'
+command_not_found_handle:5> [[ $- -regex-match i ]]
+command_not_found_handle:8> [ '!' -S /var/run/dbus/system_bus_socket ']'
+command_not_found_handle:11> [ '!' -x /usr/libexec/packagekitd ']'
+command_not_found_handle:14> [ ']'
+command_not_found_handle:17> [ 1 -eq 1 ']'
+command_not_found_handle:18> /usr/libexec/pk-command-not-found fail
zsh: fail: command not found...
+command_not_found_handle:19> retval=127
+command_not_found_handle:26> return 127
zsh: command not found: fail
  • This does not happen with another shell, then? Feb 4 '16 at 17:45
  • Correct, Added bash/tcsh output as an example. With that by side by side, it almost looks like zsh is printing the bash command not found as well as one for zsh, but i have no idea what would cause that :\
    – Gravy
    Feb 4 '16 at 17:50
  • zsh -x might be handy to see what is going on. Or, what does print $+functions[command_not_found_handler] show?
    – thrig
    Feb 4 '16 at 17:58
  • added outputs above.
    – Gravy
    Feb 4 '16 at 18:16

When a command is not found, zsh invokes the function command_not_found_handler. A typical use for this function is to suggest a way to install the command, if it's part of a package that's part of your distribution but isn't installed.

In zsh, if the function returns a nonzero status, zsh prints its usual error message. Bash has a similar feature (there the function is called command_not_found_handle), but with a slight difference: in bash, if the command returns a nonzero status, bash doesn't print an error message.

From the trace, you seem to be using oh-my-zsh. It's calling pk-command-not-found, which is Fedora's command-not-found handler, and which prints its own error message because it was designed for bash. I don't see an obvious way to suppress one of the error messages. If this really bothers you, you can remove the command-not-found plugin from your oh-my-zsh configuration (in which case you won't get prompted to install the package containing a command if it's available in the repositories but not installed).

  • Hmm, Unfortunately not actually using oh-my-zsh, so i'm not sure how i'll end up dealing with it, but what your saying at least gives me an answer. Thanks for your input.
    – Gravy
    Feb 6 '16 at 23:24
  • @Gravy If this doesn't come from your .zshrc then presumably your distribution or your system administrator has put something similar in /etc/zshrc. Feb 6 '16 at 23:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.