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

vars no longer run sh #1825

Closed
Firesphere opened this issue Sep 20, 2024 · 3 comments
Closed

vars no longer run sh #1825

Firesphere opened this issue Sep 20, 2024 · 3 comments

Comments

@Firesphere
Copy link

  • Task version: 3.39.2
  • Operating system: MacOS 15 & MacOS 14.latest
  • Experiments enabled: TASK_X_MAP_VARIABLES=1

Vars, such as this:

version: '3'

tasks:
  test:
    cmds:
      - echo {{.GIT_COMMIT}}
    vars:
      GIT_COMMIT:
        sh: git log -n 1 --format=%h

Now return

$ task test
map[sh:git log -n 1 --format=%h]

instead of the expected evaluated value.

@task-bot task-bot added the state: needs triage Waiting to be triaged by a maintainer. label Sep 20, 2024
@mgbowman
Copy link
Contributor

I believe this is expected behavior.

According to Map Variables Experiment, you are using proposal 1 (TASK_X_MAP_VARIABLES=1) which "removes support for the sh and ref keywords in favour of a new syntax"

@Firesphere
Copy link
Author

Hmmm, I must've overlooked that when I was looking if it did affect the sh .
Cool, my bad, I'll see how I can fix it a different way :)

@task-bot task-bot removed the state: needs triage Waiting to be triaged by a maintainer. label Sep 20, 2024
@pd93
Copy link
Member

pd93 commented Sep 20, 2024

@mgbowman is correct. You need to use the $ prefix instead of sh: to execute dynamic variables when TASK_X_MAP_VARIABLES=1. See https://taskfile.dev/next/experiments/map-variables/

Alternatively, you can use TASK_X_MAP_VARIABLES=2 and the behavior of sh: stays the same. Of course, you would need to define any maps using the alternative syntax instead.

Casual reminder that both these experiments could be removed in favor of the other (or neither) in the future. We're still looking for feedback on both from users in #1585.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants