[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: non-executable files in $PATH cause errors

From: Ángel
Subject: Re: non-executable files in $PATH cause errors
Date: Sun, 10 Jan 2021 16:49:50 +0100
User-agent: Evolution 3.30.5-1.1

On 2021-01-10 at 08:52 +0100, n952162 wrote:
> Hello,
> I consider it a bug that bash (and its hash functionality) includes
> non-executable files in its execution look-up and then (inevitably)
> simply reports an error, because its such files aren't  executable.
> Perhaps it's there to support PATH look up for arguments to the bash
> command.  That would also be a bug.  Why should it be okay to execute
> a
> non-executable script?  Supporting users who are too lazy to chmod a
> file ought to be less important than supporting users who want
> fine-grain control over what's executable and what's not.


I can't reproduce what you report.

$ mkdir foo bar
$ printf '#!/bin/sh\necho Program "$0"\n' > foo/program
$ printf '#!/bin/sh\necho Program "$0"\n' > bar/program
$ PATH="$PATH:$PWD/foo:$PWD/bar"
$ chmod +x bar/program 
$ program

It is executing bar/program, not foo/program which is earlier in the
path, but not executable.

Maybe you just made the earlier program not executable, and the old
path is still being remembered? You should run  hash -r  after
making executable changes that will make an already-executed command
find a different program in the path (in the example above, making
foo/program executable, or removing again its +x bit).

Best regards

reply via email to

[Prev in Thread] Current Thread [Next in Thread]