Re: Enable compgen even when programmable completions are not available?

2023-06-26 Thread Martin D Kealey
Hi Eli How about using the shell itself to parse the output of "typeset" (an alias for "declare"), but redefining "declare" to do something different. This is a bit verbose but it works cleanly: ``` ( function declare { while [[ $1 = -* ]] ; do shift ; done printf %s\\n "${@%%=*}" }

Re: Enable compgen even when programmable completions are not available?

2023-06-26 Thread Kerin Millar
On Mon, 26 Jun 2023 17:09:47 +1000 Martin D Kealey wrote: > Hi Eli > > How about using the shell itself to parse the output of "typeset" (an alias > for "declare"), but redefining "declare" to do something different. This is > a bit verbose but it works cleanly: > > ``` > ( > function declare

Re: Enable compgen even when programmable completions are not available?

2023-06-26 Thread alex xmb ratchev
On Mon, Jun 26, 2023, 00:25 Eli Schwartz wrote: > compgen is a useful builtin for inspecting information about the shell > context e.g. in scripts -- a good example of this is compgen -A function > or compgen -A variable. > > But it's not always available depending on how bash is built, which > r

Re: Enable compgen even when programmable completions are not available?

2023-06-26 Thread alex xmb ratchev
On Mon, Jun 26, 2023, 11:33 Kerin Millar wrote: > On Mon, 26 Jun 2023 17:09:47 +1000 > Martin D Kealey wrote: > > > Hi Eli > > > > How about using the shell itself to parse the output of "typeset" (an > alias > > for "declare"), but redefining "declare" to do something different. This > is > > a

Re: Enable compgen even when programmable completions are not available?

2023-06-26 Thread alex xmb ratchev
On Mon, Jun 26, 2023, 11:51 alex xmb ratchev wrote: > > > On Mon, Jun 26, 2023, 11:33 Kerin Millar wrote: > >> On Mon, 26 Jun 2023 17:09:47 +1000 >> Martin D Kealey wrote: >> >> > Hi Eli >> > >> > How about using the shell itself to parse the output of "typeset" (an >> alias >> > for "declare")

Re: Enable compgen even when programmable completions are not available?

2023-06-26 Thread alex xmb ratchev
On Mon, Jun 26, 2023, 11:55 alex xmb ratchev wrote: > > > On Mon, Jun 26, 2023, 11:51 alex xmb ratchev wrote: > >> >> >> On Mon, Jun 26, 2023, 11:33 Kerin Millar wrote: >> >>> On Mon, 26 Jun 2023 17:09:47 +1000 >>> Martin D Kealey wrote: >>> >>> > Hi Eli >>> > >>> > How about using the shell i

Re: Enable compgen even when programmable completions are not available?

2023-06-26 Thread Kerin Millar
On Mon, 26 Jun 2023 11:47:21 +0200 alex xmb ratchev wrote: > On Mon, Jun 26, 2023, 00:25 Eli Schwartz wrote: > > > compgen is a useful builtin for inspecting information about the shell > > context e.g. in scripts -- a good example of this is compgen -A function > > or compgen -A variable. > >

Re: Enable compgen even when programmable completions are not available?

2023-06-26 Thread Kerin Millar
On Mon, 26 Jun 2023 11:51:58 +0200 alex xmb ratchev wrote: > On Mon, Jun 26, 2023, 11:33 Kerin Millar wrote: > > > On Mon, 26 Jun 2023 17:09:47 +1000 > > Martin D Kealey wrote: > > > > > Hi Eli > > > > > > How about using the shell itself to parse the output of "typeset" (an > > alias > > > fo

Re: Enable compgen even when programmable completions are not available?

2023-06-26 Thread alex xmb ratchev
On Mon, Jun 26, 2023, 11:58 Kerin Millar wrote: > On Mon, 26 Jun 2023 11:47:21 +0200 > alex xmb ratchev wrote: > > > On Mon, Jun 26, 2023, 00:25 Eli Schwartz wrote: > > > > > compgen is a useful builtin for inspecting information about the shell > > > context e.g. in scripts -- a good example o

Re: Enable compgen even when programmable completions are not available?

2023-06-26 Thread Sam James
alex xmb ratchev writes: > On Mon, Jun 26, 2023, 11:55 alex xmb ratchev wrote: > >>[snip] > u also really dont need eval at all > > by the way , what does this nonsense code supposed to do >> separate between vars for future list / deletement ? If you read the linked bug, you'd find out.

Re: Enable compgen even when programmable completions are not available?

2023-06-26 Thread Kerin Millar
On Mon, 26 Jun 2023 11:55:03 +0200 alex xmb ratchev wrote: > by the way , what does this nonsense code supposed to do > separate between vars for future list / deletement ? Print all declared variable names reliably (which it doesn't). It's not as easy as you might think, by the way. -- Kerin

Re: Enable compgen even when programmable completions are not available?

2023-06-26 Thread alex xmb ratchev
On Mon, Jun 26, 2023, 12:01 Kerin Millar wrote: > On Mon, 26 Jun 2023 11:51:58 +0200 > alex xmb ratchev wrote: > > > On Mon, Jun 26, 2023, 11:33 Kerin Millar wrote: > > > > > On Mon, 26 Jun 2023 17:09:47 +1000 > > > Martin D Kealey wrote: > > > > > > > Hi Eli > > > > > > > > How about using th

Re: Enable compgen even when programmable completions are not available?

2023-06-26 Thread alex xmb ratchev
On Mon, Jun 26, 2023, 12:03 Kerin Millar wrote: > On Mon, 26 Jun 2023 11:55:03 +0200 > alex xmb ratchev wrote: > > > by the way , what does this nonsense code supposed to do > > separate between vars for future list / deletement ? > > Print all declared variable names reliably (which it doesn't)

Re: Enable compgen even when programmable completions are not available?

2023-06-26 Thread Kerin Millar
On Mon, 26 Jun 2023 12:03:47 +0200 alex xmb ratchev wrote: > On Mon, Jun 26, 2023, 12:01 Kerin Millar wrote: > > > On Mon, 26 Jun 2023 11:51:58 +0200 > > alex xmb ratchev wrote: > > > > > On Mon, Jun 26, 2023, 11:33 Kerin Millar wrote: > > > > > > > On Mon, 26 Jun 2023 17:09:47 +1000 > > > >

Re: Enable compgen even when programmable completions are not available?

2023-06-26 Thread alex xmb ratchev
On Mon, Jun 26, 2023, 12:10 Kerin Millar wrote: > On Mon, 26 Jun 2023 12:03:47 +0200 > alex xmb ratchev wrote: > > > On Mon, Jun 26, 2023, 12:01 Kerin Millar wrote: > > > > > On Mon, 26 Jun 2023 11:51:58 +0200 > > > alex xmb ratchev wrote: > > > > > > > On Mon, Jun 26, 2023, 11:33 Kerin Millar

Re: Enable compgen even when programmable completions are not available?

2023-06-26 Thread Martin D Kealey
hmm, declare -p used to print an array like ˋˋˋ declare -a array='([0]="value" [1]="value")' ˋˋˋ At some stage declare -p stopped printing the extra outer quotes, so that my approach also stops working. On Mon, 26 Jun 2023, 19:32 Kerin Millar, wrote: > On Mon, 26 Jun 2023 17:09:47 +1000 > Martin

Re: Enable compgen even when programmable completions are not available?

2023-06-26 Thread alex xmb ratchev
On Mon, Jun 26, 2023, 14:08 Martin D Kealey wrote: > hmm, declare -p used to print an array like > ˋˋˋ > declare -a array='([0]="value" [1]="value")' > ˋˋˋ > At some stage declare -p stopped printing the extra outer quotes, so that > my approach also stops working. > quotes matter to input diffe

Re: Enable compgen even when programmable completions are not available?

2023-06-26 Thread Eli Schwartz
On 6/26/23 5:32 AM, Kerin Millar wrote: > While it is understandable that an attempt to assign to certain shell > variables would be treated as an error, the combination of not > printing a diganostic message and inducing a non-interactive shell to > exit is rather confusing. Further, declare is gr

It is possible that this can be a bug

2023-06-26 Thread Hugo Napoli
Good day. Something strange is happening to me with this script that I have designed moments ago. I am a Computer Science professor, and among the subjects I teach, there is one that has to do with BASH programming. I make my own material, therefore, I have been working since last year with this c

Re: It is possible that this can be a bug

2023-06-26 Thread Dennis Williamson
On Mon, Jun 26, 2023, 11:07 AM Hugo Napoli wrote: > Good day. > > Something strange is happening to me with this script that I have designed > moments ago. > I am a Computer Science professor, and among the subjects I teach, there is > one that has to do with BASH programming. > I make my own mat

Re: EOF at PS2

2023-06-26 Thread Chet Ramey
On 6/23/23 7:11 PM, Grisha Levit wrote: I think we can have bash honor ignoreeof and not exit after delimiting the token or command while not acting quite as bizarrely as ksh88. I think the new behavior is quite reasonable. Though it does need something to allow the exit builtin to work even

Re: [PATCH] completion display interrupt leak handling

2023-06-26 Thread Chet Ramey
On 6/17/23 4:28 AM, Grisha Levit wrote: When readline's display of completion matches is interrupted, the match list is only freed for the '?' completion type but not for '!' and '@' types. I couldn't find a specific reason for that to be the case so hope this patch is an OK fix. Thanks, this

Bash Bug

2023-06-26 Thread Kaif Khan
dead.bashbug Description: Binary data

Re: It is possible that this can be a bug

2023-06-26 Thread Greg Wooledge
On Mon, Jun 26, 2023 at 03:36:58PM -0300, Hugo Napoli wrote: > #!/bin/bash > > clear > > echo "" > read -p "Ingrese un número entero de hasta 2 cifras > : " min > read -p "Ingrese otro número entero de hasta 2 cifras, mayor que el > anterior : " max > > if [[ ${#min} -gt 2 ]] || [[ ${#max}

Re: Bash Bug

2023-06-26 Thread alex xmb ratchev
if u modify PS1 , u must enclose escape / color codes in literarly \[ and \] eg PS1=$'\[\e[0;1m\]bold\[\e[0m\] ' and the err u say , looks like u didnt make that proper bind cmd On Mon, Jun 26, 2023, 19:15 Kaif Khan wrote: > >

Re: Enable compgen even when programmable completions are not available?

2023-06-26 Thread Robert Elz
Date:Mon, 26 Jun 2023 10:32:19 +0100 From:Kerin Millar Message-ID: <20230626103219.0f74c089c616248cee6ab...@plushkava.net> | Further, declare is granted special treatment, even after having been | defined as a function (which might be a bug). That will be becaus

Re: It is possible that this can be a bug

2023-06-26 Thread Dennis Williamson
On Mon, Jun 26, 2023, 2:47 PM Hugo Napoli wrote: > Dear Dennis and Martin, thank you very much for the quick response. > > From now on, I'll use *exec bash "$0" *instead of *bash "$0"*. > What I'm wondering is (now that I understand why this happened) if there > is some special situation where it

Re: xtrace ansi quoting vs shell metas

2023-06-26 Thread Chet Ramey
On 6/24/23 9:40 PM, Grisha Levit wrote: When printing the command for xtrace, if a word or assignment rhs contains a shell meta character, ansi quoting is not applied even if it otherwise should be. Thanks for the report. It seems reasonable to prioritize ansic-quoting over shell-metacharacter

Re: It is possible that this can be a bug

2023-06-26 Thread Hugo Napoli
I will, and the suggestions and examples that you both told me, were excellent, and a display of remarkable generosity and value. As an educator, I have now learned more solid criteria for teaching some BASH techniques to my students. Starting tomorrow, we will be discussing and observing all of th

leak in skip_double_quoted for funsub

2023-06-26 Thread Grisha Levit
diff --git a/subst.c b/subst.c index 215e3469..63ca3370 100644 --- a/subst.c +++ b/subst.c @@ -1042,7 +1042,7 @@ skip_double_quoted (const char *string, size_t slen, int sind, int flags) if (string[i + 1] == LPAREN) ret = extract_command_subst (string, &si, SX_NOALLOC|(flags&S

Re: Enable compgen even when programmable completions are not available?

2023-06-26 Thread Kerin Millar
On Tue, 27 Jun 2023 02:23:23 +0700 Robert Elz wrote: > Date:Mon, 26 Jun 2023 10:32:19 +0100 > From:Kerin Millar > Message-ID: <20230626103219.0f74c089c616248cee6ab...@plushkava.net> > > > | Further, declare is granted special treatment, even after having been >

Re: Bash Bug

2023-06-26 Thread alex xmb ratchev
On Tue, Jun 27, 2023, 07:23 alex xmb ratchev wrote: > > > On Tue, Jun 27, 2023, 04:55 Kaif Khan wrote: > >> Thank you for your response, but my bug is rather very simple and not >> complicated. I am attaching a video to explain the bug. >> > whats the output of declare -p PS0 PS1 PROMPT_COMMAND

Funny behaviour of associative arrays

2023-06-26 Thread n952162
Is this correct? declare -A l1 l1=([a]=b [c]=d) echo ${!l1[@]} l1=($(echo [a]=b [c]=d)) echo ${!l1[@]} $ bash  t4 c a [a]=b [c]=d If so, why?  And how can I assign a list of members to an associative array?