Skip to content

Syntax error with nested expansion inside () inside array index assignment #1211

Description

@Kamilcuk

brush version

master action artifact $ brush --version brush 0.4.0 (git:3b7d908)

bash version (for comparison)

5.3

Platform / OS

Linux

Steps to reproduce

Assign array with referencing a variable inside () inside [] of an array.

array[ ( $variable ) ]=value

Can be any variable.

Actual behavior (brush)

$ brush -xc 'a=1:2; b[12 + (${a#*:} * 3) + 2]=10; declare -p b'
error: -c: syntax error at line 1 col 29
$ brush -xc 'b[($$)]=; declare -p b'
error: -c: syntax error at line 1 col 7

Expected behavior

$ bash -xc 'a=1:2; b[12 + (${a#*:} * 3) + 2]=10; declare -p b'
+ a=1:2
+ b[12 + (${a#*:} * 3) + 2]=10
+ declare -p b
declare -a b=([20]="10")
$ bash -xc 'b[($$)]=; declare -p b'
+ b[($$)]=
+ declare -p b
declare -a b=([1044703]="")

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: compatRelated to compatibility with standard shellsbugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions