Re: ${param@a} should bypass unbound variable check or be processed ahead of it.

2024-10-21 Thread konsolebox
et -u` instances optimal by default even just by theory. That way the number of added exceptions would only matter to people who care about using `set -u`. -- konsolebox diff --git a/subst.c b/subst.c index 251eafaf..5e906c10 100644 --- a/subst.c +++ b/subst.c @@ -10142,9 +10142,9 @@ parameter_br

Re: ${param@a} should bypass unbound variable check or be processed ahead of it.

2024-10-21 Thread konsolebox
tributes is simpler. -- konsolebox

Re: ${param@a} should bypass unbound variable check or be processed ahead of it.

2024-10-07 Thread konsolebox
Changing "c == '@'" to "c == '@' && !want_attributes" in line 10145 of subst.c seems enough to fix it. -- konsolebox diff --git a/subst.c b/subst.c index 251eafaf..9ee816e0 100644 --- a/subst.c +++ b/subst.c @@ -10142,7 +10142,7 @@ parameter

${param@a} should bypass unbound variable check or be processed ahead of it.

2024-10-01 Thread konsolebox
3.0(1)-beta (x86_64-pc-linux-gnu) -- konsolebox

Re: proposed BASH_SOURCE_PATH

2024-08-06 Thread konsolebox
On Tue, Aug 6, 2024 at 3:09 PM konsolebox wrote: > > On Thu, Jul 25, 2024 at 9:10 PM Chet Ramey wrote: > > > > On 7/18/24 4:44 PM, konsolebox wrote: > > > On Thu, Jul 18, 2024 at 11:02 PM Chet Ramey wrote: > > >> > > >> On 7/11/24 3:51 AM,

Re: proposed BASH_SOURCE_PATH

2024-08-06 Thread konsolebox
On Thu, Jul 25, 2024 at 9:10 PM Chet Ramey wrote: > > On 7/18/24 4:44 PM, konsolebox wrote: > > On Thu, Jul 18, 2024 at 11:02 PM Chet Ramey wrote: > >> > >> On 7/11/24 3:51 AM, konsolebox wrote: > >>> On Thu, Jul 11, 2024 at 4:08 AM Chet Ramey wrote:

Re: proposed BASH_SOURCE_PATH

2024-07-18 Thread konsolebox
On Thu, Jul 18, 2024 at 11:02 PM Chet Ramey wrote: > > On 7/11/24 3:51 AM, konsolebox wrote: > > On Thu, Jul 11, 2024 at 4:08 AM Chet Ramey wrote: > >> and the BASH_SOURCE > >> absolute pathname discussion has been bananas, so that's not going in any > &

Re: proposed BASH_SOURCE_PATH

2024-07-11 Thread konsolebox
On Thu, Jul 11, 2024 at 4:08 AM Chet Ramey wrote: > and the BASH_SOURCE > absolute pathname discussion has been bananas, so that's not going in any > time soon. Maybe just create BASH_SOURCE_REAL instead to avoid the gripes. https://gist.github.com/konsolebox/d9fb2fadd2b8b13d96

Re: proposed BASH_SOURCE_PATH

2024-07-03 Thread konsolebox
or source are full paths. But I think it's better to be consistent. It comes with fewer surprises and usage rules. -- konsolebox

Re: proposed BASH_SOURCE_PATH

2024-07-03 Thread konsolebox
On Mon, Jul 1, 2024 at 10:56 PM Chet Ramey wrote: > > On 6/26/24 5:59 AM, konsolebox wrote: > > On Tue, Jun 25, 2024 at 11:14 PM Chet Ramey wrote: > >> > >> On 6/19/24 6:12 PM, konsolebox wrote: > >> > >>> Alternatively, have BASH_SOURCE always

Re: anonymous pipes in recursive function calls

2024-07-01 Thread konsolebox
en at the same time, unnecessarily allowing more room for unexpected errors. Isn't that worse? It doesn't matter if bash seamlessly allows multiple recursion-generated pipes or not. Your use case at some point may be practical but it's the one that should be questioned first. Storing output is the sane choice in most cases. -- konsolebox

Re: anonymous pipes in recursive function calls

2024-06-29 Thread konsolebox
On Sat, Jun 29, 2024 at 10:23 PM Zachary Santer wrote: > > On Sat, Jun 29, 2024 at 4:40 AM konsolebox wrote: > > > > You can avoid pipe recursions by storing the output first in an array. > > So is this a known issue? I don't know. I haven't really checked y

Re: anonymous pipes in recursive function calls

2024-06-29 Thread konsolebox
entry_path}/${path}" || return fi ... done cd -- "${starting_PWD}" - You can also just use a 'die' function if cleanups aren't needed. Anything is valid in a contained code. -- konsolebox

Re: proposed BASH_SOURCE_PATH

2024-06-26 Thread konsolebox
oment they are accessed. I still prefer the simpler one however, which is to just assign real paths to BASH_SOURCE by default. -- konsolebox

Re: proposed BASH_SOURCE_PATH

2024-06-26 Thread konsolebox
On Tue, Jun 25, 2024 at 11:14 PM Chet Ramey wrote: > > On 6/19/24 6:12 PM, konsolebox wrote: > > > Alternatively, have BASH_SOURCE always produce real physical paths > > either by default or through a shopt. > > This is the best option. I don't think changing ba

Re: proposed BASH_SOURCE_PATH

2024-06-21 Thread konsolebox
means you have to store the context directories to another list. -- konsolebox

Re: proposed BASH_SOURCE_PATH

2024-06-19 Thread konsolebox
paths either by default or through a shopt. Any additional feature that doesn't allow loading a script relative to the caller without external help is practically useless. -- konsolebox

Re: proposed BASH_SOURCE_PATH

2024-06-19 Thread konsolebox
rting `-m`. It is mostly convenient if you only need to load a single script. For example: source "$(realpath -m "${BASH_SOURCE}/../../lib/script.bash")" || exit -- konsolebox

Re: [PATCH] fix uneccesary copy of function bodies for BASH_SOURCE

2024-06-03 Thread konsolebox
t time they are called. For example they can call a script containing the proper implementation with heavier code. Or simplify themselves depending on the environment or the available tools they detect at first run. -- konsolebox

Re: [PATCH v2 5/8] builtins/source: parse the -i option

2024-05-20 Thread konsolebox
On Tue, May 21, 2024 at 4:10 AM Chet Ramey wrote: > > On 5/20/24 3:39 AM, konsolebox wrote: > > > It's rare for a topic about adding an import/include function to get > > so much attention like this I think it's time Bash takes the > > opportunity t

Re: [PATCH v2 5/8] builtins/source: parse the -i option

2024-05-20 Thread konsolebox
this I think it's time Bash takes the opportunity to implement it and hopefully properly. -- konsolebox

Re: [PATCH v2 5/8] builtins/source: parse the -i option

2024-05-19 Thread konsolebox
On Sun, May 19, 2024 at 7:01 AM Matheus Afonso Martins Moreira wrote: > > > The issue is that what you want, and what I want, > > and what konsolebox wants (and everyone else) > > are all slightly different. > > The option solution which I proposed is not really in op

${var/\#} no longer works

2024-05-19 Thread konsolebox
Here's an output from devel branch bash and 5.2.26: $ bash-9 -c 'echo "$BASH_VERSION"; x="abc#xyz"; echo "${x/\#}"' 5.3.0(1)-alpha abc#xyz $ bash-5.2.26 -c 'echo "$BASH_VERSION"; x="abc#xyz"; echo "${x/\#}"' 5.2.26(1)-release abcxyz -- konsolebox

Re: proposed BASH_SOURCE_PATH

2024-05-18 Thread konsolebox
On Sat, May 18, 2024 at 9:18 AM Martin D Kealey wrote: > On Thu, 16 May 2024 at 22:50, konsolebox wrote: >> >> On Thu, May 16, 2024 at 4:59 PM Martin D Kealey >> wrote: >> > As I understood your counter-proposal, it would result in this: >> > * ./a and

Re: source -i prototype implementation and other features

2024-05-18 Thread konsolebox
I also uploaded a copy of the script and the patch to gist: https://gist.github.com/konsolebox/a908cf13e511abdf05daec89a9cbdd8d -- konsolebox

source -i prototype implementation and other features

2024-05-18 Thread konsolebox
/shell.h index b9d259a5..721e0086 100644 --- a/shell.h +++ b/shell.h @@ -246,3 +246,5 @@ extern void uw_restore_parser_state (void *); extern sh_input_line_state_t *save_input_line_state (sh_input_line_state_t *); extern void restore_input_line_state (sh_input_line_state_t *); + +extern char *sh_physpath (char *, int); The recommended way to use the script is by placing it to a common PATH location like /usr/local/bin and name it as 'source-extensions'. Scripts can import it by simply calling `source source-extensions` before other source commands. Consistency before simplicity. -- konsolebox

Re: proposed BASH_SOURCE_PATH

2024-05-16 Thread konsolebox
On Thu, May 16, 2024 at 4:59 PM Martin D Kealey wrote: > On Wed, 15 May 2024 at 16:33, konsolebox wrote: >> >> On Wed, May 15, 2024 at 7:16 AM Martin D Kealey >> wrote: >> >> > I'm concerned that doing both would introduce an entirely new dichotomy >

Re: proposed BASH_SOURCE_PATH

2024-05-14 Thread konsolebox
;? No. `source` already searches PATH when ./ isn't provided. That's already intuitive. In C, you don't specify ./ as well when referring to relative paths in #include. No one should ever get used to using ./ when referring to relative paths. -- konsolebox

Re: proposed BASH_SOURCE_PATH

2024-05-14 Thread konsolebox
should be considered explicit so if you want lib/foo.bash to load relative to BASH_SOURCE_PATH's ".", just specify "lib/foo.bash". -- konsolebox On Tue, May 14, 2024 at 2:09 PM Martin D Kealey wrote: > > I wholeheartedly support the introduction of BASH_SOURCE_PATH,

Re: Re: [PATCH 0/4] Add import builtin

2024-05-08 Thread konsolebox
ear-old framework too. Thank you very much. :) https://loader.sourceforge.io/overview/ -- konsolebox

Re: Feature Request: Allow compgen to store results on a variable

2023-09-02 Thread konsolebox
On Mon, Feb 21, 2022 at 2:23 AM konsolebox wrote: > > Commonly `readarray -t`, a pipe, and a subshell is used to get the > results of compgen but this has two problems: > > - It uses a pipe and a subshell > - Values having newlines will be split > > Those can be preven

Re: Allow `read` to recognize custom completions

2023-09-02 Thread konsolebox
On Mon, Jun 21, 2021 at 11:34 PM Chet Ramey wrote: > I'll consider it. It's low priority right now. Hello Chet, I just saw this implemented in 5.3. Just want to say thanks a lot!! I extremely appreciate it. -- konsolebox

New instances of Bash should ignore and reset BASH_ARGV0

2022-10-09 Thread konsolebox
This doesn't look right to me: # export BASH_ARGV0=fdsafasfas # bash # echo "$BASH_ARGV0|$0" fdsafasfas|fdsafasfas # echo $BASH_VERSION 5.2.0(1)-release -- konsolebox

Re: Feature request

2022-07-22 Thread konsolebox
ction name is same as script) or 'utils..' since the dot is allowed in Bash. For the global variables used in each script, I have them all capitalized and prefixed with the name of the "namespace", like "UTILS__". It risks conflict with global and builtin variables but adds easy distinguishability vs. just using lowercase letters prefixed with an underscore. Optionally an underscore can be prefixed to avoid the conflict but I haven't really needed it so far besides on a few shared (just, probably) ones. I also do have an extended "include" function that accepts wildcards best used for loading dynamic yet managed sub-scripts. -- konsolebox

Re: 5.2-alpha completion script source crash

2022-03-21 Thread konsolebox
On Sat, Feb 19, 2022 at 9:34 PM Chet Ramey wrote: > Thanks for the report. This is the result of needing to clean up parser > state before recursively calling it to parse the command substitution. Just tested devel. This one's fixed as well. -- konsolebox

Re: 5.2-alpha prompt broken on next line

2022-03-21 Thread konsolebox
On Mon, Mar 21, 2022 at 7:11 PM Chet Ramey wrote: > Isn't this the same as > > https://lists.gnu.org/archive/html/bug-readline/2022-02/msg00038.html ? > > That's already fixed. I'm sorry I didn't check. Yes it's already fixed. -- konsolebox

5.2-alpha prompt broken on next line

2022-03-21 Thread konsolebox
ckspace to be typed to be triggered. I can't reproduce it with 5.1.4 and 5.1.16. All tested versions have their bundled readlines compiled with them. -- konsolebox

Re: Feature Request: Add option to make completed values always become properly escaped

2022-03-09 Thread konsolebox
On Mon, Mar 7, 2022, 23:16 Chet Ramey, wrote: > On 2/26/22 2:01 PM, konsolebox wrote: > > > I think an option like 'escape' that simply escapes COMPREPLY > > values when used for completion and doesn't compare it to existing > > filesystem objects will be

Re: Feature Request: Add option to make completed values always become properly escaped

2022-02-26 Thread konsolebox
On Fri, Feb 25, 2022 at 2:46 PM Chet Ramey wrote: > > On 2/25/22 3:29 AM, konsolebox wrote: > > On Mon, Feb 21, 2022 at 4:32 PM Chet Ramey wrote: > >> What does `properly quoted' mean here and how does it differ from the > >> quoting you get when you force c

Re: Feature Request: Add option to make completed values always become properly escaped

2022-02-25 Thread konsolebox
On Fri, Feb 25, 2022 at 8:29 AM konsolebox wrote: > What I need more is an option that allows replacing the current > word including the quote (', ", or $') that begins it with the result > as is rather than appending the result to the quote. ... because the result is alr

Re: Feature Request: Add option to make completed values always become properly escaped

2022-02-25 Thread konsolebox
lash to the result when the result matches a directory. For example, "test" which refers to a task becomes "test/". -- konsolebox

Feature Request: Add option to make completed values always become properly escaped

2022-02-20 Thread konsolebox
be properly quoted, this manual quoting hacks wouldn't be needed. -- konsolebox

Feature Request: Allow compgen to store results on a variable

2022-02-20 Thread konsolebox
Commonly `readarray -t`, a pipe, and a subshell is used to get the results of compgen but this has two problems: - It uses a pipe and a subshell - Values having newlines will be split Those can be prevented if another option is added. E.g.: compgen -O array_var ... -- konsolebox

5.2-alpha completion script source crash

2022-02-19 Thread konsolebox
ns it and exits well. Compiling it with a safer flag like `-ggdb3 -O -pipe` didn't help. -- konsolebox

Re: Empty array referenced by indirection reports unbound variable

2022-02-06 Thread konsolebox
On Mon, Feb 7, 2022, 00:31 Chet Ramey, wrote: > From CHANGES: > > ... Well I'm glad. Thanks again! -- konsolebox

Re: Empty array referenced by indirection reports unbound variable

2022-02-06 Thread konsolebox
On Thu, Dec 30, 2021 at 4:35 PM Chet Ramey wrote: > Let's try it. Thanks for the report. It seems to be already fixed in 5.2-alpha (thanks), but I can't see it mentioned in the changelog. Can you kindly confirm if it really is? -- konsolebox

Re: Bash not escaping escape sequences in directory names

2022-01-24 Thread konsolebox
ta that is needed. > That would be reasonable, the \x nonsense (the PSx escapes) aren't. Thanks for the details. I at least agree with not using \w and \W here if anyone wants to escape literal escape sequences, or wait till bash adds a generous feature that escapes any valid terminal code. -- konsolebox

Re: Bash not escaping escape sequences in directory names

2022-01-24 Thread konsolebox
On Tue, Jan 25, 2022, 06:24 Robert Elz, wrote: > Date:Tue, 25 Jan 2022 05:45:23 +0800 > From: konsolebox > Message-ID: < > cajnmqwbvrbdijqcu8+oo0gvic7onew8nkv4djfyy3o5eepm...@mail.gmail.com> > > | As for me whatever it is, it should be done

Re: Bash not escaping escape sequences in directory names

2022-01-24 Thread konsolebox
ogether with Chet's and Greg's mail; All around good and > reasonable things said by people I trust to say sensible things about > the shell. Thanks. I'll stand down from my "you need to do something > right now" position. > > Take care, > As for me whatever it is, it should be done consistently and with no compromise. No matter how "slightly broken" it is or no matter unlikely it is to occur it should be fixed. Post filename expansion or population processes should not make any interpretation of the expanded filenames in whatsoever manner. -- konsolebox

Re: Empty array referenced by indirection reports unbound variable

2021-12-30 Thread konsolebox
On Thu, Dec 30, 2021 at 4:35 PM Chet Ramey wrote: > > On 12/27/21 11:37 PM, konsolebox wrote: > > On Thu, Apr 8, 2021, 06:56 konsolebox, > <mailto:konsole...@gmail.com>> wrote: > > > > On Thu, Apr 8, 2021 at 2:44 AM Chet Ramey >

Re: Allow `read` to recognize custom completions

2021-12-27 Thread konsolebox
On Mon, Jun 21, 2021, 23:34 Chet Ramey, wrote: > On 6/16/21 2:04 AM, konsolebox wrote: > > > Thanks, that worked well. Is there a chance a feature that would > > allow this be defaulty implemented in the next version? If yes, what > > would be the strategy

Re: Empty array referenced by indirection reports unbound variable

2021-12-27 Thread konsolebox
On Thu, Apr 8, 2021, 06:56 konsolebox, wrote: > On Thu, Apr 8, 2021 at 2:44 AM Chet Ramey wrote: > > Indirection does not check whether or not the variable it's indirecting > > is $@/$* or ${array[@/*]}. It simply goes by the return value. > > It looks like it can

Re: Add {{ }}, ${{ }}, return n [x], and $:

2021-12-27 Thread konsolebox
cripts more portable, which means other > implementors > are under no pressure to copy the feature...Implemented optimisations > for the standard shell syntax simply work, and improve performance, while > still allowing the script to work anywhere. > I'm not really concerned about portability for this. Bash has always made its own fruitful implementations. -- konsolebox

Re: Add {{ }}, ${{ }}, return n [x], and $:

2021-12-27 Thread konsolebox
To Chet: Any thoughts on this? -- konsolebox

Re: Space vs. non-space separators in COMP_WORDBREAKS

2021-12-22 Thread konsolebox
ds to be documented. It makes use of a single parameter but interprets its values differently. Anyway at least I now know the behavior is intended, so I don't really mind how this goes. -- konsolebox

Re: Zero-length indexed arrays

2021-12-22 Thread konsolebox
On Wed, Dec 22, 2021 at 4:07 AM Greg Wooledge wrote: > I would recommend not using set -u. > Especially > when you need to support multiple bash versions, or even multiple shells. It's still useful during development stages. -- konsolebox

Feature Request: Allow each completion to have their own wordbreaks

2021-12-18 Thread konsolebox
ociative array variable that can contain the name of the completion as the key and the value as the word break characters. -- konsolebox

Re: Space vs. non-space separators in COMP_WORDBREAKS

2021-12-17 Thread konsolebox
On Fri, Dec 17, 2021 at 7:13 PM Chet Ramey wrote: > > On 12/17/21 2:00 PM, konsolebox wrote: > > On Sat, Dec 18, 2021, 00:49 Chet Ramey, wrote: > >> Well, the documentation says the line gets broken into words the way > >> readline does it, and r

Re: Space vs. non-space separators in COMP_WORDBREAKS

2021-12-17 Thread konsolebox
nce on how a separator is kept like rl_special_prefixes but none of them seems to have anything to do with the space character. -- konsolebox

Re: Have a method to prevent space from being added after an invalid one-result completion

2021-12-17 Thread konsolebox
Nevermind I found a way. The trick is to enable nospace by default and add space manually to only result when result is 1 and is valid. -- konsolebox

Have a method to prevent space from being added after an invalid one-result completion

2021-12-17 Thread konsolebox
t appearing in the completions. -- konsolebox

Space vs. non-space separators in COMP_WORDBREAKS

2021-12-16 Thread konsolebox
n't spaces are also passed as an argument and stored in COMP_WORDS. This surprised me a bit, and I think it would be helpful if this behavior gets documented as well. Tested with 5.1.12. -- konsolebox

Re: Allow `read` to recognize custom completions

2021-06-15 Thread konsolebox
On Wed, Jun 2, 2021, 10:27 konsolebox, wrote: > On Tue, May 25, 2021 at 4:36 AM Chet Ramey wrote: > > > > On 5/22/21 8:29 AM, konsolebox wrote: > > > `read -e` doesn't recognize custom completions (at least on my basic > > > observations). For exampl

Re: Allow `read` to recognize custom completions

2021-06-01 Thread konsolebox
On Tue, May 25, 2021 at 4:36 AM Chet Ramey wrote: > > On 5/22/21 8:29 AM, konsolebox wrote: > > `read -e` doesn't recognize custom completions (at least on my basic > > observations). For example, if I enable `complete -IW 'someword > > another-word'`,

Allow `read` to recognize custom completions

2021-05-22 Thread konsolebox
utocomplete the commands that are accepted. Perhaps adding a shell option that enables this or another option to read like -E would be sensible. -- konsolebox

Re: Add {{ }}, ${{ }}, return n [x], and $:

2021-04-30 Thread konsolebox
On Fri, Apr 30, 2021 at 4:09 PM Robert Elz wrote: > > Date:Fri, 30 Apr 2021 14:53:58 +0800 > From:konsolebox > Message-ID: > > > | {{ }} - Similar to { }, but runs like a function so variables can be > | declared local > > From

Add {{ }}, ${{ }}, return n [x], and $:

2021-04-29 Thread konsolebox
global variable when unsetting an iterator in an initialization script to keep the variables clean, even just by theory. -- konsolebox

Re: [PATCH] Skip initial expansion of valid array reference tokens in unset

2021-04-19 Thread konsolebox
I'll just skip that as I would also have to modify other declarations for consistency. I think the code is already good enough for a proof of concept at least. -- konsolebox

Re: [PATCH] Skip initial expansion of valid array reference tokens in unset

2021-04-19 Thread konsolebox
unsigned int flags; /* Flags associated with this word. */ > `y.tab.c' is automatically generated from `parse.y'. You should edit > `parse.y' instead of `y.tab.c' I also modified parse.y. All changes made so far can be seen in https://git.io/JOam0. Thanks for the tips. -- konsolebox

[PATCH] Free unfreed string in assign_assoc_from_kvlist()

2021-04-19 Thread konsolebox
aval = (char *)xmalloc (1); aval[0] = '\0'; /* like do_assignment_internal */ - free_aval = 1; } bind_assoc_var_internal (var, h, akey, aval, flags); - if (free_aval) - free (aval); + free (aval); } } -- konsolebox

[PATCH] Skip initial expansion of valid array reference tokens in unset

2021-04-19 Thread konsolebox
also available in https://github.com/konsolebox/bash/tree/skip_expansion_of_valid_array_refs_in_unset. The patch is applied against the latest commit (f3a35a2d60) in master branch. The changes can be conveniently compared in https://git.io/JOgrE. The solution allows the following tests to pass. A

Re: Changing the way bash expands associative array subscripts

2021-04-18 Thread konsolebox
t going to go that way without much better reasons than I've seen > so far. There's less reason to choose a complicated solution that adds thinking overhead, adds inconsistencies and breaks scripts. Making unset skip default word expansion on tokens that pass valid_array_reference () is much simpler. -- konsolebox

Re: Changing the way bash expands associative array subscripts

2021-04-15 Thread konsolebox
On Fri, Apr 16, 2021 at 12:10 AM Chet Ramey wrote: > > I actually agree with konsolebox that assoc_expand_once for unset > > shouldn't be defaulted. The option `assoc_expand_once' is incomplete > > in the sense that the behavior of `a[@]' and `a[*]' are

Re: Changing the way bash expands associative array subscripts

2021-04-13 Thread konsolebox
ak scripts. The only change I'd want is have `unset 'a[@]'` only unset the elements and not the array itself. -- konsolebox

Re: When "set -u", "which" outputs environment: line 1: _declare: unbound

2021-04-09 Thread konsolebox
s or external commands is a function. Try `type which`. -- konsolebox

Re: Changing the way bash expands associative array subscripts

2021-04-09 Thread konsolebox
my_function { local my_function__a another_function my_function__a } This solution applies to namerefs, indirections and evil eval. Keeping the passed references sane is up to the scripter. -- konsolebox

Re: Changing the way bash expands associative array subscripts

2021-04-08 Thread konsolebox
On Fri, Apr 9, 2021 at 8:17 AM konsolebox wrote: > It's a definite shell feature despite lacking internal sanity checks. *despite having limited -- konsolebox

Re: Changing the way bash expands associative array subscripts

2021-04-08 Thread konsolebox
king internal sanity checks. -- konsolebox

Re: Changing the way bash expands associative array subscripts

2021-04-08 Thread konsolebox
On Fri, Apr 9, 2021 at 3:21 AM Chet Ramey wrote: > > On 4/6/21 11:42 AM, konsolebox wrote: > > > Or maybe just completely avoid this new behaviors and allow another > > way to unset an element of an array. > > > > a[$key]=() > > a[@]=() > > While thi

Re: Changing the way bash expands associative array subscripts

2021-04-08 Thread konsolebox
On Fri, Apr 9, 2021 at 2:19 AM Chet Ramey wrote: > What is your end goal? To run the same script on different versions of > bash, or something else? Nevermind. I overthinked. -- konsolebox

Re: Empty array referenced by indirection reports unbound variable

2021-04-07 Thread konsolebox
rrayref = 1; + } +} + else if (valid_array_reference (name, 0)) { int qflags; char *t; -- konsolebox

Re: Empty array referenced by indirection reports unbound variable

2021-04-07 Thread konsolebox
On Wed, Apr 7, 2021 at 9:25 PM Chet Ramey wrote: > > On 4/5/21 4:45 PM, konsolebox wrote: > > set -u > > array=() > > __ref=array[@] > > : "${array[@]}" # Reports nothing > > This is a special case, mirroring the special case that POSIX carved

Re: Changing the way bash expands associative array subscripts

2021-04-06 Thread konsolebox
the clearest example I can give is Java's LinkedHashMap. -- konsolebox

Re: Changing the way bash expands associative array subscripts

2021-04-06 Thread konsolebox
On Wed, Apr 7, 2021 at 12:20 AM Ilkka Virta wrote: > What konsolebox said about a[$k]=() works in my Zsh for indexed arrays, but > not associative ones. > (It replaces an array slice, so can also be used to insert elements in the > middle.) Bash can adopt this. Also if Bash coul

Re: Changing the way bash expands associative array subscripts

2021-04-06 Thread konsolebox
of the arguments of the `unset' builtin is the cleanest way > to solve the problem of `key=@; unset -v a[$key]'. Or maybe just completely avoid this new behaviors and allow another way to unset an element of an array. a[$key]=() a[@]=() I think a shell already does this. Not sure if it's from ksh, zsh, or pdksh. -- konsolebox

Re: Empty array referenced by indirection reports unbound variable

2021-04-06 Thread konsolebox
d don't expand the referenced target themselves. ${!__ref} is synonymous to ${array[@]}, not ${${array[@]}}. This is why you can do other parameter expansion features like ${!var+.} ${!var@a}. -- konsolebox

Re: Empty array referenced by indirection reports unbound variable

2021-04-06 Thread konsolebox
verything or nothing. Unbound variable errors should not apply to it. -- konsolebox

Re: Empty array referenced by indirection reports unbound variable

2021-04-06 Thread konsolebox
On Tue, Apr 6, 2021 at 9:57 PM Alex fxmbsw7 Ratchev wrote: > > arr=( ) implies no [0]= Also `arr=()` does not imply `arr[0]=`. `arr[0]` remains unset and not assigned to any. Not even an empty string. -- konsolebox

Re: Empty array referenced by indirection reports unbound variable

2021-04-06 Thread konsolebox
On Tue, Apr 6, 2021 at 9:57 PM Alex fxmbsw7 Ratchev wrote: > > arr=( ) implies no [0]= arr[0] is not exactly being referenced here. -- konsolebox

Re: Changing the way bash expands associative array subscripts

2021-04-05 Thread konsolebox
On Mon, Apr 5, 2021 at 9:44 PM Chet Ramey wrote: > > On 4/1/21 3:02 PM, konsolebox wrote: > > >> To do what, exactly? > > > > To keep this working in both behaviors. > > > > declare -A a > > key='$(echo foo)' > > a[$key]=1 > &

Empty array referenced by indirection reports unbound variable

2021-04-05 Thread konsolebox
le functions to have less versions. The detection of unbound variables seem to have become more reasonable since 5.0 and I hope it gets improved further. I don't use set -u in older bash and it's only for development mode. -- konsolebox

Re: No such device or address when opening /dev/fd/ on opened /dev/tcp socket

2021-04-05 Thread konsolebox
doesn't generate that error on macOS, for instance, which has /dev/fd. Thanks. I'll take note of it for future reference. -- konsolebox

Re: No such device or address when opening /dev/fd/ on opened /dev/tcp socket

2021-04-05 Thread konsolebox
gt;/dev/tcp/host/port' Nice strategies. -- konsolebox

No such device or address when opening /dev/fd/ on opened /dev/tcp socket

2021-04-05 Thread konsolebox
s like this does the same: # echo a | tee /dev/fd/4 4>/dev/tcp/host/port # echo a | ( tee /dev/fd/4 ) 4>/dev/tcp/host/port The workaround is to use process substitution and cat: # echo a | tee >( cat > /dev/tcp/host/port ) Tested in 5.1.4. -- konsolebox

Re: select syntax violates the POLA

2021-04-04 Thread konsolebox
2150. They are labeled as "Reserved words". -- konsolebox

Re: select syntax violates the POLA

2021-04-04 Thread konsolebox
with them as well. This should have been explicitly allowed by the shell. It's highly doable even if they are followed with non-keywords. Just look at awk's syntax. -- konsolebox

Re: select syntax violates the POLA

2021-04-02 Thread konsolebox
reserved words themselves just like () and {} as they can be used multi-line but they aren't allowed to be adjacent to else et al without a semicolon. [[ ]], (( )), {}, and () are practically just commands with first-class parsing that consistently have to end with a semicolon if followed by another reserved word or command. -- konsolebox

Re: select syntax violates the POLA

2021-04-02 Thread konsolebox
t; rule. > > The right question would be why '} else' works. Indeed. This inconsistency should be fixed and prevent people from using it wrong. `}; else` should work but not `} else` just like how `{ :; } :` doesn't. -- konsolebox

Re: Changing the way bash expands associative array subscripts

2021-04-01 Thread konsolebox
On Fri, Apr 2, 2021 at 3:02 AM konsolebox wrote: > > On Fri, Apr 2, 2021 at 2:56 AM Chet Ramey wrote: > > > > On 4/1/21 2:55 PM, konsolebox wrote: > > > > > So to keep compatibility, would this be the right way? > > > > > > if [[ BASH_VERSINFO

Re: Changing the way bash expands associative array subscripts

2021-04-01 Thread konsolebox
On Fri, Apr 2, 2021 at 2:56 AM Chet Ramey wrote: > > On 4/1/21 2:55 PM, konsolebox wrote: > > > So to keep compatibility, would this be the right way? > > > > if [[ BASH_VERSINFO -ge 6 || BASH_VERSINFO -eq 5 && BASH_VERSINFO -ge 2 ]]; > >

  1   2   3   >