[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 0/4] Add import builtin
From: |
Lawrence Velázquez |
Subject: |
Re: [PATCH 0/4] Add import builtin |
Date: |
Thu, 02 May 2024 22:15:31 -0400 |
User-agent: |
Cyrus-JMAP/3.11.0-alpha0-417-gddc99d37d-fm-hotfix-20240424.001-g2c179674 |
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
- [PATCH 0/4] Add import builtin, Matheus Afonso Martins Moreira, 2024/05/02
- [PATCH 1/4] builtins: extract file content executor function, Matheus Afonso Martins Moreira, 2024/05/02
- [PATCH 3/4] findcmd: define the user import finder function, Matheus Afonso Martins Moreira, 2024/05/02
- [PATCH 4/4] builtins: add import builtin, Matheus Afonso Martins Moreira, 2024/05/02
- [PATCH 2/4] findcmd: parameterize path variable in functions, Matheus Afonso Martins Moreira, 2024/05/02
- Re: [PATCH 0/4] Add import builtin, Dale R. Worley, 2024/05/02
- Re: [PATCH 0/4] Add import builtin,
Lawrence Velázquez <=
- Re: [PATCH 0/4] Add import builtin, Koichi Murase, 2024/05/02