On Fri, Jun 14, 2024 at 02:13:37AM +0800, Dan Jacobson wrote:
> $ echo \#!/usr/bin/python > k
> $ chmod +x k
> $ ./k
> bash: ./k: cannot execute: required file not found
> 
> Bash should really mention what file it is talking about.

Bash doesn't KNOW what file is missing.  All it knows is that the
kernel said "No such file or directory", and bash used to report
exactly that.  The message was changed to be more informative (bash
realizes that the *command file* exists, but the kernel still said
ENOENT, so bash gives you this message instead of the generic one).

The only way to know what file is missing is to dive into the operating
system's internals, with system-specific knowledge and tools.  You,
as a human, can do that.  Bash should never be expected to.

(In case you weren't aware, you will get the same message, for the same
reasons, if /usr/bin/python exists but it's missing a shared library or
an architecture-specific ld.so type loader program.  Your current
example may look simplistic, but it's just a tip-of-the-iceberg type
thing.)

Reply via email to