[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Re: Re: [PATCH 0/4] Add import builtin
From: |
Phi Debian |
Subject: |
Re: Re: Re: [PATCH 0/4] Add import builtin |
Date: |
Sun, 5 May 2024 11:33:18 +0200 |
On Sat, May 4, 2024 at 4:44 AM Matheus Afonso Martins Moreira <
matheus@matheusmoreira.com> wrote:
>
> By "library system" I just mean the exact mechanism through which
> bash will load a "library". By "library", I mean ordinary scripts
> whose purpose is to collect related functions and variables
> for reuse by other scripts or interactive bash users.
>
May be that's why the term 'library' is not very well suitable as there are
other ways to load functions and variables in a shell context, i.e shared
libraries/objets dynamic builtins, so the 'import got to cover all of none.
In this case the import would find the shared libs in the restricted path
IMPORT_PATH along with the scripts, and then a 'library' could either be
text script or binary .so a.out.
Sounds more like a pandora box :-)
> By introducing the "module/library system" I want to do the following:
>
> 1. Add a builtin primitive that can be used to load libraries
> 2. Establish a convention for where bash will look for libraries
> 3. Separate the libraries from the commands/executables
>
If its all that simple may this 3 liners to stick in your.rc file or hide
it in yet another . findable script
shopt -s expand_aliases # Some may dislike this
xyz_import='for xyz in ${XYZ_IMPORT_PATH//:/\/$1 }/$1;do xyz=$(realpath -q
$xyz);[ -r "$xyz" ]&&. $xyz&&return;done'
alias xyz_import='source /dev/stdin <<< "$xyz_import"'
1. It create a new primitive (well a command in shell parser vocable)
xyz_import
2. It Establish a convention for where bash will look for libraries
XYZ_IMPORT_PATH
3. Separate the libraries from the commands/executables by looking in the
$XYZ_IMPORT_PATH dir set only
Murphy's law
------------
Note the I namespaced all this with xyz/XYZ, change for your taste, but
beware of other 'import'
While testing this I discover (and forgot) that I installed the
'imagemagick' package (linux debian) which in turn setup an alternative
path on 'import'
$ ll /usr/bin/import
lrwxrwxrwx 1 root root 24 Feb 26 07:43 /usr/bin/import ->
/etc/alternatives/import
$ ll /etc/alternatives/import
lrwxrwxrwx 1 root root 23 Feb 26 07:43 /etc/alternatives/import ->
/usr/bin/import-im6.q16
So I guess it is wise to stay away from 'import' name.
- Re: Re: [PATCH 0/4] Add import builtin, (continued)
- Re: Re: [PATCH 0/4] Add import builtin, Matheus Afonso Martins Moreira, 2024/05/08
- Re: [PATCH 0/4] Add import builtin, Chet Ramey, 2024/05/07
- Re: [PATCH 0/4] Add import builtin, Chet Ramey, 2024/05/07
- Re: [PATCH 0/4] Add import builtin, Lawrence Velázquez, 2024/05/07
- Re: [PATCH 0/4] Add import builtin, Matheus Afonso Martins Moreira, 2024/05/07
- Re: [PATCH 0/4] Add import builtin, Chet Ramey, 2024/05/08
- Re: Re: [PATCH 0/4] Add import builtin, Matheus Afonso Martins Moreira, 2024/05/08
- Re: Re: Re: Re: [PATCH 0/4] Add import builtin, Koichi Murase, 2024/05/06
- Re: Re: Re: [PATCH 0/4] Add import builtin, Martin D Kealey, 2024/05/07
- Re: Re: Re: [PATCH 0/4] Add import builtin, Koichi Murase, 2024/05/08
- Re: Re: Re: [PATCH 0/4] Add import builtin,
Phi Debian <=
- Re: Re: [PATCH 0/4] Add import builtin, konsolebox, 2024/05/08
Re: [PATCH 0/4] Add import builtin, Chet Ramey, 2024/05/03
Re: [PATCH 0/4] Add import builtin, Robert Elz, 2024/05/03