> Neither of these requires a new builtin command.
> They require changes to the shell, since they differ from
> existing functionality, but those changes don't have to
> take the form of a builtin.

Builtin was not the correct word for what I meant.
I meant to say there were advantages to implementing
this as a change in bash, in contrast to implementing
it a an external function.

It's true that BASH_SOURCE_PATH would solve the problem
and it would be a very welcome change to the shell.
I will be very happy if support for that is added.

I also agree that the attempt to introduce a new builtin
was misguided and I have already abandoned it.
This email thread belongs to the first patch set I sent,
I followed up with a more conservative approach that
adds an option to the source builtin. I'm currently
preparing a v2 patch set which incorporates all
the feedback I've received.

> It takes less than a dozen lines of code
> to implement BASH_SOURCE_PATH.

The actual code implementing the feature
in the source builtin is in that range.
These are the changes I made which truly
implement the feature:

    variables: define default BASH_LIBRARIES_PATH
        config-top.h | 7 +++++++
        variables.c  | 1 +
    builtins/source: search libraries in library mode
        builtins/source.def | 5 ++++-

About half of the patch was just some reorganization.
I tried to make the code better as I went along,
so that the final implementation would be shorter.

Some of those changes had unintended consequences
such as exposing a function to builtins as an API.
Others were not desired such as long option support.
They will be dropped in the v2 patch set,
which will be much smaller.

  -- Matheus

Reply via email to