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

Re: PATH_DIRS



On Thu, Aug 10, 2017 at 10:07 PM, Ray Andrews <rayandrews@xxxxxxxxxxx> wrote:
> On 10/08/17 03:19 PM, Bart Schaefer wrote:
>>
>> Anyway, it already does search like that.  You just have to chmod +x
>> the script files (and add a #! line if they aren't zsh scripts).
>
> However, scripts are run even if chmod -x, tho whence will only find them if
> '+x'.   Am I somehow missing the boat there?

You're confusing scripts read with the "." (or "source") commands with
programs that are found by path search where the program happens to be
a script.

That is, with or without PATH_DIRS set, if you have a script named
"myscript" in a directory in $PATH and you chmod +x it, then you can
run it by just typing "myscript" in command position, without
prefixing it by ". ".  With PATH_DIRS set, you can run ". myscript"
with or without that executable permission on the file (it need only
be readable).

When I said:

>> What it WON'T do is source scripts it finds that way into the current
>> shell.

By "that way" I meant "path search where the program happens to be a
script."  Obviously (I hope), the "." command always does source
things into the current shell.

> I find myself wanting whence to find anything that is executable on the PATH.

Some people use "chmod +x" on scripts exactly for this reason, whether
they intend to always run them via the "." command or not.



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