On Thu, Oct 19, 2023, 16:58 Chet Ramey wrote:
> On 10/17/23 3:32 PM, Grisha Levit wrote:
>
> > The reason is that if there was no variable found prior to expanding
> > the subscript, bash does not check to see if one was created during
> > that process.
>
> Thanks, I'll consider it. Behavior
On 10/17/23 3:32 PM, Grisha Levit wrote:
The reason is that if there was no variable found prior to expanding
the subscript, bash does not check to see if one was created during
that process.
Thanks, I'll consider it. Behavior varies across shells in this area.
Chet
--
``The lyf so short,
On Tue, Oct 17, 2023, 10:48 Christoph Anton Mitterer
wrote:
>
> On Tue, 2023-10-17 at 00:26 -0400, Grisha Levit wrote:
> > The array subscript can an arbitrary arithmetic expression with side
> > effects, so it makes sense to perform the expansion even if the array
> > whose subscript is being
On Tue, Oct 17, 2023, at 10:48 AM, Christoph Anton Mitterer wrote:
> As Lawrence pointed out:
> $ set -u
> $ declare -A a
> $ echo ${a[k]}
> bash: a[k]: unbound variable
>
> Here it actually looks first at a (which turns out to be an associative
> array) and thus doesn't even bother to evaluate
On Tue, 2023-10-17 at 00:26 -0400, Grisha Levit wrote:
> The array subscript can an arbitrary arithmetic expression with side
> effects, so it makes sense to perform the expansion even if the array
> whose subscript is being expanded is unset:
Okay... that's all pretty convoluted. I assume it
On Tue, Oct 17, 2023, 16:30 Chet Ramey wrote:
> On 10/17/23 8:43 AM, Zachary Santer wrote:
> > On Tue, Oct 17, 2023 at 8:00 AM Greg Wooledge wrote:
> >
> >> unicorn:~$ unset -v a b c array
> >> unicorn:~$ a=b b=c c=42 array[a]=foo; declare -p array
> >> declare -a
On 10/17/23 8:43 AM, Zachary Santer wrote:
On Tue, Oct 17, 2023 at 8:00 AM Greg Wooledge wrote:
unicorn:~$ unset -v a b c array
unicorn:~$ a=b b=c c=42 array[a]=foo; declare -p array
declare -a array=([42]="foo")
What? What is Bash doing here? Dereferencing iteratively until
On Tue, Oct 17, 2023, 15:09 Zachary Santer wrote:
> On Tue, Oct 17, 2023 at 8:43 AM Zachary Santer wrote:
>
> > On Tue, Oct 17, 2023 at 8:00 AM Greg Wooledge wrote:
> >
> >> unicorn:~$ unset -v a b c array
> >> unicorn:~$ a=b b=c c=42 array[a]=foo; declare -p array
> >> declare -a
On Tue, Oct 17, 2023 at 8:43 AM Zachary Santer wrote:
> On Tue, Oct 17, 2023 at 8:00 AM Greg Wooledge wrote:
>
>> unicorn:~$ unset -v a b c array
>> unicorn:~$ a=b b=c c=42 array[a]=foo; declare -p array
>> declare -a array=([42]="foo")
>>
> What? What is Bash doing here?
On Tue, Oct 17, 2023 at 8:00 AM Greg Wooledge wrote:
> unicorn:~$ unset -v a b c array
> unicorn:~$ a=b b=c c=42 array[a]=foo; declare -p array
> declare -a array=([42]="foo")
>
What? What is Bash doing here? Dereferencing iteratively until it finds
something it can do arithmetic
On Tue, Oct 17, 2023 at 04:46:22AM +0200, Christoph Anton Mitterer wrote:
> But why does it even try to evaluate the subscript "key" as arithmetic
> expression?
Because that's how indexed arrays work. Everything inside the square
brackets is an arithmetic expression, and in an arithmetic
On Mon, Oct 16, 2023, 22:46 Christoph Anton Mitterer
wrote:
> Hey.
>
> On Mon, 2023-10-16 at 22:05 -0400, Lawrence Velázquez wrote:
> > Under no circumstances should your examples complain about "array"
> > because they do not attempt to expand it. As I demonstrated, your
> > examples do not
Hey.
On Mon, 2023-10-16 at 22:05 -0400, Lawrence Velázquez wrote:
> Under no circumstances should your examples complain about "array"
> because they do not attempt to expand it. As I demonstrated, your
> examples do not even complain about unset scalar variables.
Okay I realise now, why it
On Mon, Oct 16, 2023, at 9:06 PM, Christoph Anton Mitterer wrote:
> $ set -u
> $ [ -n "${array[key]+is_set}" ] && echo is set || echo not set
> bash: key: unbound variable
> $ [[ -v array[key] ]] && echo is set || echo not set
> bash: key: unbound variable
Since "array" has not been declared at
Hey.
On 5.2.15 I've noticed the following:
$ set -u
$ [ -n "${array[key]+is_set}" ] && echo is set || echo not set
bash: key: unbound variable
$ [[ -v array[key] ]] && echo is set || echo not set
bash: key: unbound variable
$ declare -A array
$ [ -n "${array[key]+is_set}" ] && echo is set ||
15 matches
Mail list logo