[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 0/4] Add import builtin
From: |
Matheus Afonso Martins Moreira |
Subject: |
[PATCH 0/4] Add import builtin |
Date: |
Thu, 2 May 2024 19:22:29 -0300 |
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.
The simplest possible solution would be to add a special operating mode
to the existing source builtin to make it behave in the desired way.
However, that would overload an already overloaded builtin even further.
There are already complexities in how it works due to POSIX compliance.
This would add to those complexities.
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.
Care was taken not to duplicate existing code.
The needed functionality was split off from existing code
and into parameterized helper functions that both the old
and the new code could use.
Matheus Afonso Martins Moreira (4):
builtins: extract file content executor function
findcmd: parameterize path variable in functions
findcmd: define the user import finder function
builtins: add import builtin
AUTHORS | 1 +
MANIFEST | 1 +
Makefile.in | 4 +-
builtins/Makefile.in | 6 ++-
builtins/common.c | 64 ++++++++++++++++++++++++++++
builtins/common.h | 1 +
builtins/import.def | 99 ++++++++++++++++++++++++++++++++++++++++++++
builtins/source.def | 62 ++-------------------------
findcmd.c | 37 +++++++++++------
findcmd.h | 1 +
10 files changed, 202 insertions(+), 74 deletions(-)
create mode 100644 builtins/import.def
--
2.44.0
- [PATCH 0/4] Add import builtin,
Matheus Afonso Martins Moreira <=
- [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, 2024/05/02