On Thu, May 2, 2024, at 6:22 PM, Matheus Afonso Martins Moreira wrote: > Bash scripts can be hard to get right so reusing proven solutions > as shell script libraries is of immense value. However, the existing > shell script sourcing mechanisms are suboptimal for this task. > The source builtin uses the PATH variable for resolving file names > which means they would have to be placed alongside normal executables > which could cause confusion.
This is debatable. Augmenting PATH with a directory containing nonexecutable scripts for sourcing is IMO not that confusing. > This patch set introduces a new "import" builtin which behaves just like > the source builtin but only looks up executables in the BASH_IMPORT_PATH > variable. I really don't think "'source' with a different search path" merits a separate builtin. This could be accomplished by creating a new path variable and modifying "source" to use it. (Perhaps "source" could diverge from "." on this, in which case there wouldn't be a POSIX conformance issue.) Put another way, "." already has an identical synonym in "source". If it's deemed desirable to fiddle with sourcing behavior, I think it makes more sense to utilize "source" than to introduce a third, almost-but-not-quite-identical synonym. If "import" were qualitatively different from "source" (say it integrated some sort of namespace functionality), then it would be more compelling. -- vq