As also ewhac pointed out, the error messages differ because the latter command line contains forward slashes (/
), which causes your shell to interpret it as a file path.
Both errors originate from your shell, which in this case is bash
(which is evident from the second error message).
More specifically, the first error originates from the execute_disk_command()
function defined in execute_command.c
in the bash-4.2
source code. The execute_disk_command()
function calls search_for_command()
defined in findcmd.c
, which, in case the specified pathname
does not contain forward slashes, searches $PATH
for the pathname
. In case pathname
contains forward slashes, search_for_command()
does not perform this lookup. In case search_for_command()
does not return a command, execute_disk_command()
will fail with the command not found
internal error.
The second error originates from the shell_execve()
function, also defined in execute_command.c
. At this point in your scenario,search_for_command()
would have returned successfully because there would not have been any lookup needed, and execute_disk_command()
has called shell_execve()
, which in turn performs the execve()
system call. This fails, because the file execve()
attempts to execute does not exist, and execve()
indicates this by setting errno
appropriately. When execve()
fails, shell_execve()
uses strerror()
to report the corresponding file error message (No such file or directory
) and exits the shell immediately on the error.
/
), which causes you shell to interpret it as a file path. Keep in mind that/
is the directory separator in Unix-like OS:s, and cannot be present in a filename. – Thomas Nyman Oct 25 '13 at 6:41bash
in this case. See my answer below for more details on the code paths which lead to the respective errors. – Thomas Nyman Oct 25 '13 at 8:07