bug-bash
[Top][All Lists]
Advanced

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

Re: proposed BASH_SOURCE_PATH


From: Martin D Kealey
Subject: Re: proposed BASH_SOURCE_PATH
Date: Wed, 15 May 2024 11:15:54 +1200

On Tue, 14 May 2024 at 20:10, konsolebox <konsolebox@gmail.com> wrote:

> On Tue, May 14, 2024 at 2:09 PM Martin D Kealey <martin@kurahaupo.gen.nz>
> wrote:
> > 2. Search BASH_SOURCE_PATH when any relative path is given, not just a
> path
> > that lacks a '/', so that libraries can be organized into subdirectories.
>
> I disagree with this.  Paths beginning with ./ or ../ should be
> considered explicit and not searched in BASH_SOURCE_PATH.
>
> It should use the directory of the calling script as reference when
> using -i or $PWD when not.
>

For the particular cases of './' and '../' that seems reasonable when the
fallback is the location of the script (proposal 4), but in general I would
prefer "source -i foo/bar/zing" to honour BASH_SOURCE_PATH.

I'm concerned that doing both would introduce an entirely new dichotomy for
programmers to have to remember, so perhaps "skip path searching" should be
controlled by a separate switch, perhaps '-s'?

Yes one could instead write "BASH_SOURCE_PATH='' source -i ...", but that
would mess up the search path for inner source commands, and avoiding that
is one of the reasons for doing this in the first place. (And yet again I'm
wishing that "local" could be used outside functions.)

-Martin


reply via email to

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