Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression #785, Associative array is broken. #1908

Open
kundeng opened this issue Nov 6, 2024 · 4 comments
Open

Regression #785, Associative array is broken. #1908

kundeng opened this issue Nov 6, 2024 · 4 comments
Labels
dep: mvdan/sh Issues related to the upstream interpreter used by Task.

Comments

@kundeng
Copy link

kundeng commented Nov 6, 2024

Regression #785
I'm using the nix version of Task version: 3.39.2

declare -A database_lookup
        database_lookup["management"]=management
        database_lookup["devicetwin"]=devicetwin
        database_lookup["identity"]=identity
        
        for d in "${!database_lookup[@]}"
        do
          echo $d
        done

The above code just prints "0".

@task-bot task-bot added the state: needs triage Waiting to be triaged by a maintainer. label Nov 6, 2024
@kundeng
Copy link
Author

kundeng commented Nov 6, 2024

I tried the brew version 3.33.1 and I got the same result as well.

@pd93
Copy link
Member

pd93 commented Nov 6, 2024

As with #785, this will need to be filed upstream with https://github.com/mvdan/sh

@pd93 pd93 added type: bug Something not working as intended. dep: mvdan/sh Issues related to the upstream interpreter used by Task. and removed state: needs triage Waiting to be triaged by a maintainer. labels Nov 6, 2024
@kundeng
Copy link
Author

kundeng commented Nov 6, 2024

I filed a bug here: mvdan/sh#1108

@kundeng
Copy link
Author

kundeng commented Nov 6, 2024

I downloaded the earlier version that was supposed to have the fix but that version 3.14.0 doesn't work either:

Here is the test script:

version: '3.2'

tasks:
  test:
    desc: "This taskfile manages Docker stacks."
    cmds:
      - |
        declare -A database_lookup
        database_lookup["management"]=management
        database_lookup["devicetwin"]=devicetwin
        database_lookup["identity"]=identity
        
        for d in "${!database_lookup[@]}"
        do
          echo $d
        done 
      - | 
        bash test.sh

The output is:

./task -t test.yml test
task: [test] declare -A database_lookup
database_lookup["management"]=management
database_lookup["devicetwin"]=devicetwin
database_lookup["identity"]=identity

for d in "${!database_lookup[@]}"
do
  echo $d
done 

0
task: [test] bash test.sh
identity
devicetwin
management

@pd93 pd93 removed the type: bug Something not working as intended. label Dec 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dep: mvdan/sh Issues related to the upstream interpreter used by Task.
Projects
None yet
Development

No branches or pull requests

3 participants