Completely agree with your suggestions.
I've proposed suggestion 3 as well in previous
emails but consensus was not reached.
-- Matheus
I wholeheartedly support the introduction of BASH_SOURCE_PATH, but I would
like to suggest three tweaks to its semantics.
A common pattern is to unpack a script with its associated library & config
files into a new directory, which then leaves a problem locating the
library files whose paths are o
> The patches touch the interface of many functions
I added one external function: find_in_path_var.
The other changes are all static and local.
> It seems essentially equivalent to just calling
> find_in_path (list->word->word, path_value ("BASH_SOURCE_PATH", 1),
> FS_READABLE);
It is. I'm
> I think we should restrict the search in
> BASH_SOURCE_PATH and shouldn't fall back to local files.
I concur but thought it'd be wise to discuss it first so I left it in.
Users might expect it to respect the configuration option.
I also saw that many of the PATH-like variable defaults
had the cu
2024年5月13日(月) 19:38 Matheus Afonso Martins Moreira
:
> The PATH variable is hard coded in the user command finder function.
> Transforming it into an argument allows reusing the file finding logic
> with variables other than PATH, making the code more flexible.
I think what was suggested by Chet i
2024年5月13日(月) 19:39 Matheus Afonso Martins Moreira
:
> Extract into a dedicated helper function the code which loads
> the contents of a file and executes it in the current shell.
> This separates this useful functionality from the path resolution
> mechanism used by the source builtin.
To other r
2024年5月13日(月) 19:40 Matheus Afonso Martins Moreira
:
> diff --git a/builtins/source.def b/builtins/source.def
> index 26040e70..7f870bfe 100644
> --- a/builtins/source.def
> +++ b/builtins/source.def
> @@ -177,6 +178,27 @@ search_for_file (WORD_LIST *list)
> [...]
> +static char *
> +isolated_searc
On Monday, May 13, 2024, Chet Ramey wrote:
> performs the setpgid in the process forked
> to run the process substitution).
>
Yes, this sounds like the easy way. I don't know how else to prevent the
race in OP. Close stdin/stdout? Direct it from /dev/null?
--
Oğuz
On 5/12/24 10:00 AM, Oğuz wrote:
On Sun, May 12, 2024 at 4:33 PM Andreas Schwab wrote:
Since the redirection fails and the cat command is never started, bash
doesn't switch the terminal process group
It does on my computer:
554 ioctl(255, TIOCSPGRP, [554]) = 0
553 execve("/usr/bin/w
In 5.3-alpha, it is no longer possible to quote the special % and #
characters in a pattern replacement expansion.
$ a=1/%2/%3
$ echo "${a/\%/##}"
1/%2/%3##
$ echo "${a/\/%/##}"
1##2/%3
The second example shows that quoting still works as expected for
${PARAMETER//PATTERN/STRING}.
--
Andreas Sc
Define a build time configurable default value
for the new BASH_SOURCE_PATH variable.
Look for libraries in the user's home directory
as well as the system wide directories.
Signed-off-by: Matheus Afonso Martins Moreira
---
config-top.h | 7 +++
variables.c | 1 +
2 files changed, 8 inserti
Behave normally when executed without any options.
Search only BASH_SOURCE_PATH for scripts to source
when isolated mode is enabled via the -i option.
Signed-off-by: Matheus Afonso Martins Moreira
---
builtins/source.def | 27 ++-
1 file changed, 26 insertions(+), 1 delet
Make the BASH_SOURCE_PATH variable read-only and unsettable
when the shell is operating in restricted mode. This variable
should be restricted for the same reasons why PATH is restricted.
Signed-off-by: Matheus Afonso Martins Moreira
---
shell.c | 1 +
1 file changed, 1 insertion(+)
diff --git
Extract the file searching algorithm of the source builtin into
a static helper function. Makes the code easier to understand
and separates the searching from the error handling logic.
Signed-off-by: Matheus Afonso Martins Moreira
---
builtins/source.def | 59 +++-
Passing the -i option to the source builtin
enables isolated sourcing mode which restricts
its search path to the directories defined by
the BASH_SOURCE_PATH variable. This also has
the added benefit of not touching PATH at all.
To maximize compatibility, the option will only
be recognized outside
It works just like the find_in_path function
but takes a PATH-like variable name instead.
This allows defining and using more PATH-like
variables much more easily.
Signed-off-by: Matheus Afonso Martins Moreira
---
findcmd.c | 7 +++
findcmd.h | 1 +
2 files changed, 8 insertions(+)
diff --g
Extract into a dedicated helper function the code which loads
the contents of a file and executes it in the current shell.
This separates this useful functionality from the path resolution
mechanism used by the source builtin.
Signed-off-by: Matheus Afonso Martins Moreira
---
builtins/source.def
The PATH variable is hard coded in the user command finder function.
Transforming it into an argument allows reusing the file finding logic
with variables other than PATH, making the code more flexible.
Signed-off-by: Matheus Afonso Martins Moreira
---
findcmd.c | 25 +
1
Bash scripts can be tricky 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
19 matches
Mail list logo