3

I just typed crash in my ZSH (from oh-my-zsh if that matters) and I got peculiar answer:

zsh: permission denied: crash

instead of the usual command-not-found behaviour expected (since I have that plugin installed).

Please help me understand why or point me in where I can debug this. Other words don't trigger any such message, it's the usual command not found behaviour. type crash states crash not found.

➜  ~ crash
zsh: permission denied: crash
➜  ~ type crash
crash not found
➜  ~ type crashaa
crashaa not found
➜  ~ type crsdadsadsa
crsdadsadsa not found
➜  ~ ieusrferw
zsh: command not found: ieusrferw
➜  ~ crashaa
zsh: command not found: crashaa
➜  ~ crash
zsh: permission denied: crash

Curiosity got the best of me: sudo crash reports sudo: crash: command not found. :P

Thank you @Gilles and @StéphaneChavelaz, for prompt hints:

  1. set -x gave a lot of output, but core didn't change, right after command being executed there's no permission. I'll copy/paste output once I understand it a bit more :-)
  2. No, I don't have the crash directory, I even created a temp aaa dir and repeated things there, no change. Nor do I remember setting crash on path. Also, sudo doesn't help, well, it shows "no such command".
3

I can reproduce it if I create a directory called crash in any of the directories in $path:

$ mkdir -p ~/bin/crash
$ path+=(~/bin)
$ crash
zsh: permission denied: crash
$ type crasn
crasn not found

The permission denied would be because zsh tries to execute that directory (and there's no other crash potential command to look for in the rest of $path). Now that type doesn't report that directory when zsh tries to execute it when you enter crash could be seen as a bug.

Try ls -ld -- $^path/crash(N/) to confirm.

dash, tcsh (with which) and fish have the same problem. ksh93 and mksh have a similar inconsistency, but at least their error message is more helpful:

$ ksh -c crash
ksh: crash: cannot execute [Is a directory]
$ ksh -c 'type crash'
ksh: whence: crash: not found
  • Precisely what it was. <bows deeply> Nice touch with regexing the $path shell var without error messages for non-existing dirs (N/). I learned something nice, thank you. Another nice touch is extending the answer with other shells and commands. Unfortunately I can only upvote once! :( Thank you again! – LAFK says Reinstate Monica Mar 2 '17 at 23:55

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.