Re: Bash-5.2-alpha available
On 3/11/22 3:35 AM, Andreas Schwab wrote: This is still mixing up undo history: I took it out. I could not make it work the way I wanted it to without more extensive changes to the rest of readline than I was willing to make. -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, UTech, CWRUc...@case.eduhttp://tiswww.cwru.edu/~chet/
Re: 5.2-alpha completion script source crash
On 3/21/22 6:33 PM, konsolebox wrote: 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. That was the implication, yes. :-) -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, UTech, CWRUc...@case.eduhttp://tiswww.cwru.edu/~chet/
Re: Bash-5.2-alpha available
I still see clobbered history lines: bash-5.2$ history 1 echo 1 2 echo 2 3 echo 3 4 history Type e, *2, bash-5.2$ echo 2 2 bash-5.2$ history 1 echo 1 2 echo 2 3* echo 2 4 history 5 echo 2 6 history Line 3 should not be modified just because I moved over it. -- Andreas Schwab, sch...@linux-m68k.org GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1 "And now for something completely different."
Re: Bash-5.2-alpha available
On 3/22/22 10:00 AM, Andreas Schwab wrote: I still see clobbered history lines: I took it out. That version isn't in the devel branch yet. -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, UTech, CWRUc...@case.eduhttp://tiswww.cwru.edu/~chet/
Re: for loop over parameter expansion of array can miss resulted empty list
On 2022/03/21 03:40, Alex fxmbsw7 Ratchev wrote: i solve this by shopt -s nullglob Repeat-By: Code: x=("/"); for i in "${x[@]%/}"; do echo "i is '$i'"; done Result: none Expected result: i is '' if you have nullglob set, then that is not the correct result. I used: #!/bin/bash echo "x=${x[@]%/}" for i in "${x[@]%/}"; do echo "i is <$i>" done I got: /tmp/x x= To display what you want, use '*' for the array expansion. #!/bin/bash echo "x=${x[*]%/}" for i in "${x[*]%/}"; do echo "i is <$i>" done this gives: /tmp/x x= i is <> Reason: "[@]" displays each element in quotes. If there are no elements, then it is a null list, as in () resulting in '0' loop runs. if you use [*]...all elements are concatenated and the result is quoted, thus you will always have 1 element and the loop will always be run, at least, once.
Re: [Bug Report] The Unexpected Behavior When Using ANSI Escape Code
On 2022/03/20 02:20, Michaelll Lee wrote: When ``PS1’’ environment variable contains the ANSI escape codes, Bash will behavior unexpectedly when Copy&Paste the content from clipboard using Ctrl+V. This unexpected behaviour could be easily reproduced in a few steps. Reproduceable steps are: 1) $ PS1='---Test \\ \e[0m ---\\$ ' The '\e[0m' is not an ANSI escape code. It's a directive to your terminal to do something. If you are talking to your terminal, that's above bash in the process chain, and bash can't really do anything about that. Some terminal might allow '\eexec[0mCMD' Bash can't control what your terminal emulator does as it is outside of bash.
Re: for loop over parameter expansion of array can miss resulted empty list
On Tue, Mar 22, 2022, at 4:53 PM, L A Walsh wrote: > On 2022/03/21 03:40, Alex fxmbsw7 Ratchev wrote: >> i solve this by shopt -s nullglob >> >>> >>> Repeat-By: >>>Code: x=("/"); for i in "${x[@]%/}"; do echo "i is '$i'"; done >>>Result: none >>>Expected result: i is '' >>> > if you have nullglob set, then that is not the correct result. The original bug report said nothing about nullglob. -- vq
Re: parameter expansion null check fails for arrays when [*] or [@] is used
On 2022/03/21 05:45, Andreas Luik wrote: Description: Bash fails to correctly test for parameter to be unset or null when the parameter is an array reference [*] or [@]. Repeat-By: myvar[0]= echo "${myvar[0]:+nonnull}" -> OK echo "${myvar[*]:+nonnull}" nunnull -> not OK, because "${myvar[*]}" is null myvar[*] = ('', ) element 0 contains an empty string, so not null. echo "${myvar[@]:+nonnull}" nunnull -> likewise not OK, because "${myvar[@]}" is null myvar[@] = '' (displays all elements, each quoted. Since element 1 contains an empty string, it is quoted and isn't null.
Re: for loop over parameter expansion of array can miss resulted empty list
On 2022/03/22 13:53, L A Walsh wrote: On 2022/03/21 03:40, Alex fxmbsw7 Ratchev wrote: i solve this by shopt -s nullglob Repeat-By: Code: x=("/"); for i in "${x[@]%/}"; do echo "i is '$i'"; done Result: none Expected result: i is '' BTW -- try adding "-u" on your bash line. Then you'll see what is really null vs. containing a ''.
Re: for loop over parameter expansion of array can miss resulted empty list
On 2022/03/22 14:04, Lawrence Velázquez wrote: On Tue, Mar 22, 2022, at 4:53 PM, L A Walsh wrote: On 2022/03/21 03:40, Alex fxmbsw7 Ratchev wrote: i solve this by shopt -s nullglob Repeat-By: Code: x=("/"); for i in "${x[@]%/}"; do echo "i is '$i'"; done Result: none Expected result: i is '' if you have nullglob set, then that is not the correct result. The original bug report said nothing about nullglob. Sorry, I got sidetracked. In this case it wouldn't matter, if you have no directories where you are running this, then nothing will match, and it will be a null (empty) expression. The for i in X [Y [Z]], statement will execute once for each non-null value after the 'in'. If there are no expressions, then it won't execute. Thus there should be no output. If you wanted to gather up dir names in the current directory, I'd use something like: readarray -t -d '' dirs< <(find . -maxdepth 1 -type d -print0) dirs=${dirs[@]#./} Sorry for my getting sidetracked (it happens alot. find . -type d -print
Re: for loop over parameter expansion of array can miss resulted empty list
On Tue, Mar 22, 2022 at 08:05:21PM -0700, L A Walsh wrote: > > > > > Repeat-By: > > > > >Code: x=("/"); for i in "${x[@]%/}"; do echo "i is '$i'"; done > > > > >Result: none > > > > >Expected result: i is '' > Sorry, I got sidetracked. In this case it wouldn't matter, > if you have no directories where you are running this, > then nothing will match, and it > will be a null (empty) expression. The > for i in X [Y [Z]], statement will execute once for each > non-null value after the 'in'. If there are no expressions, > then it won't execute. Thus there should be no output. The array 'x' has one element in it, so "${x[@]}" should expand to one word. Likewise, one would expect "${x[@]%whatever}" to expand to a single word also, regardless of the actual content of the array, or the value of 'whatever'. Prior to bash 4.2, it did.
Re: for loop over parameter expansion of array can miss resulted empty list
On Tue, Mar 22, 2022, at 11:05 PM, L A Walsh wrote: > On 2022/03/22 14:04, Lawrence Velázquez wrote: >> On Tue, Mar 22, 2022, at 4:53 PM, L A Walsh wrote: >> >>> On 2022/03/21 03:40, Alex fxmbsw7 Ratchev wrote: >>> i solve this by shopt -s nullglob > Repeat-By: >Code: x=("/"); for i in "${x[@]%/}"; do echo "i is '$i'"; done >Result: none >Expected result: i is '' > > >>> if you have nullglob set, then that is not the correct result. >>> >> >> The original bug report said nothing about nullglob. >> > > Sorry, I got sidetracked. In this case it wouldn't matter, > if you have no directories where you are running this, > then nothing will match, and it > will be a null (empty) expression. The contents of the current working directory don't come into play, as the original test case does not perform any filename generation. Note that nearly everything there is quoted. > Sorry for my getting sidetracked (it happens alot. No worries. -- vq