On 5/21/24 1:55 AM, Phi Debian wrote:

The idea started before the current discussion as a way to avoid
overloading PATH in the source builtin:

https://lists.gnu.org/archive/html/help-bash/2024-04/msg00022.html


Some thought 'source' was a good candidate for this, except that source is
a read/parse/eval feature while the intention was more a read/parse for the
benefit of the 'importer'

You can't import function definitions without the `eval' step.


so construct like
hobbit:~$ PATH=. source bar

is perfectly ledgit if we are honest and admit bar is an import only and
execute no code, simply bring functions.

So PATH=$BASH_SOURCE_DIR . greatlib

is the way to go, still assuming libs are functions/vars only and no code
execution.

As soon as the 'library' concept assume that eval is also possible, along
with read/parse, then kaboom we need PATH back so the
PATH=$PATH:/path/to/lib .

There are workarounds for this, but they would require these package
managers to change.

Real life package actually require the eval, because it is the way to
configure a 'library' depending the user context.

Same.


'May be' bash could investigate the ksh93/zsh $FPATH autoload, but don't
know if that would be good enough for the initial purpose.

Apparently not, since there's been an example autoload function in the tree
for 30 years.

--
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    c...@case.edu    http://tiswww.cwru.edu/~chet/


Reply via email to