Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Weird behaviour



* On Sat, Apr 02, 2011 at 05:05:29PM -0700, Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
On Apr 3,  2:30am, Raghavendra D Prabhu wrote:
}
} Xye% ""
} zsh: permission denied:
} ============================
} Is this a bug or some weird quirk ?

Neither, exactly.

You've asked the shell to execute the command named (empty string) found
anywhere in the directories named in $PATH.

Bash searches the path and finds no executable file named (empty string)
so it gives up and prints "command not found".

Zsh does the same search, but instead of giving up at the end it repeats
the attempt with actual execve() system calls, so as to find the "real"
error that the operating system would report if you were to have typed
out the full path to the command.  That error is "permission denied"
because (any directory name)/(empty string) is the same as the directory
itself, and directories can't be executed as commands.

Aside:  As it happens, if you were to have typed out the full path in
bash, it first calls execve(), but when that fails with "permission
denied" bash goes one step further and stat()s the path to determine
if it is a directory, and if so prints "is a directory" instead of the
permission error.
Cool. Thanks for the explanation.
--------------------------
Raghavendra Prabhu
GPG ID:D72BE977

Attachment: pgpXzaaMChaN2.pgp
Description: PGP signature



Messages sorted by: Reverse Date, Date, Thread, Author