Re: With DEBUG trap, resizing window crashes script

2023-05-10 Thread Eduardo Bustamante
On Wed, May 10, 2023 at 1:03 PM Wiley Young wrote: > (...) > The script is set up to enable the DEBUG trap and prompt. When the first > user prompt appears, in this case `set -x` although xtrace was enabled at > the crashbang, if I resize the window then press enter, the script dies and > displa

RE: nounset option: Error message points to the wrong variable when accessing associative arrays

2023-05-10 Thread Baumann, Moritz
> ⚠️ STOP USING [[ -v "assoc[$key]" ]]! DO NOT USE IT! ⚠️ > > [...] > > Use [[ -v 'assoc[$key]' ]] instead, so that -v can expand the variable > correctly by itself: Thank you for the warning, I somehow forgot about this behavior even though the manual mentions it explicitly. > Also, especiall

With DEBUG trap, resizing window crashes script

2023-05-10 Thread Wiley Young
From: liveuser To: bug-bash@gnu.org Subject: With DEBUG trap, resizing window crashes script Configuration Information [Automatically generated, do not change]: Machine: x86_64 OS: linux-gnu Compiler: gcc Compilation CFLAGS: -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -

Re: nounset option: Error message points to the wrong variable when accessing associative arrays

2023-05-10 Thread alex xmb ratchev
On Wed, May 10, 2023, 19:45 Baumann, Moritz wrote: > > Anyway, that is still correct behaviour; the reason why that happens is > > that when you assign you perform an array expansion on a variable that > > is neither a -a nor a -A variable, the variable is treated as a -a > > (indexed array) vari

Re: nounset option: Error message points to the wrong variable when accessing associative arrays

2023-05-10 Thread Emanuele Torre
On Wed, May 10, 2023 at 05:44:54PM +, Baumann, Moritz wrote: > In the case that lead me to submit this report, the error even occurred > inside a check for the existence of an array key, which made the resulting > message even weirder: > > if [[ -v "mistyped_array[$1]" ]]; then > ... > fi ⚠

RE: nounset option: Error message points to the wrong variable when accessing associative arrays

2023-05-10 Thread Baumann, Moritz
> Anyway, that is still correct behaviour; the reason why that happens is > that when you assign you perform an array expansion on a variable that > is neither a -a nor a -A variable, the variable is treated as a -a > (indexed array) variable. Thank you for the explanation. I was immediately wonde

Re: nounset option: Error message points to the wrong variable when accessing associative arrays

2023-05-10 Thread Emanuele Torre
On Wed, May 10, 2023 at 05:25:35PM +0200, Emanuele Torre wrote: > On Wed, May 10, 2023 at 02:07:46PM +, Baumann, Moritz wrote: > > Description: > > When the nounset option is set, and you try to access a key of an > > associative array that does not exist, the error message comp

Re: nounset option: Error message points to the wrong variable when accessing associative arrays

2023-05-10 Thread Andreas Schwab
On Mai 10 2023, Baumann, Moritz wrote: > Repeat-By: > set -u > declare -r -A myarray=( [foo]='bar' ) > # typo in name of the associative array > echo ${my_array[foo]} > > Expected output: bash: my_array: unbound variable > Actual output: bash: foo: u

Re: nounset option: Error message points to the wrong variable when accessing associative arrays

2023-05-10 Thread Emanuele Torre
On Wed, May 10, 2023 at 02:07:46PM +, Baumann, Moritz wrote: > Configuration Information [Automatically generated, do not change]: > Machine: x86_64 > OS: linux-musl > Compiler: gcc > Compilation CFLAGS: -Os -Wformat -Werror=format-security > -Werror=int-conversion -DSYS_BASHRC='/etc/bash/bash

nounset option: Error message points to the wrong variable when accessing associative arrays

2023-05-10 Thread Baumann, Moritz
Configuration Information [Automatically generated, do not change]: Machine: x86_64 OS: linux-musl Compiler: gcc Compilation CFLAGS: -Os -Wformat -Werror=format-security -Werror=int-conversion -DSYS_BASHRC='/etc/bash/bashrc' -g uname output: Linux 9c586e87b370 5.15.90.1-microsoft-standard-WSL2 #1

Re: eval '`' reports error but $? is still 0

2023-05-10 Thread Emanuele Torre
On Wed, May 10, 2023 at 09:05:20PM +0800, Clark Wang wrote: > See the following example (with 5.2.15): > > bash-5.2$ PS1='$? >> ' > 0 >> eval '`' > bash: unexpected EOF while looking for matching ``' > 0 >><-- press ENTER > 2 >><-- now $? is 2 > > > It looks like the failed eval

eval '`' reports error but $? is still 0

2023-05-10 Thread Clark Wang
See the following example (with 5.2.15): bash-5.2$ PS1='$? >> ' 0 >> eval '`' bash: unexpected EOF while looking for matching ``' 0 >><-- press ENTER 2 >><-- now $? is 2 It looks like the failed eval '`' is still waiting for some input?