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

v3: expansion doesn't work as expected #336

Closed
kovetskiy opened this issue May 30, 2020 · 2 comments
Closed

v3: expansion doesn't work as expected #336

kovetskiy opened this issue May 30, 2020 · 2 comments
Labels
area: variables Changes related to variables.
Milestone

Comments

@kovetskiy
Copy link
Contributor

I'm using latest version of v3 branch

Taskfile.yml

version: '3'

vars:
  root: 'x'
  exp: 'exp-{{.root}}'

tasks:
  test:
    desc: a
    cmds:
      - echo root is '{{.root}}'
      - echo but exp is '{{.exp}}'

Current output:

$ task test root=y
task: echo root is 'y'
root is y
task: echo but exp is 'exp-x'
but exp is exp-x

$ task root=y test
task: echo root is 'y'
root is y
task: echo but exp is 'exp-y'
but exp is exp-y

Expected: both variants should output the same — exp variable should be exp-y because root is y.

@andreynering andreynering added v3 area: variables Changes related to variables. labels May 31, 2020
@andreynering
Copy link
Member

Hi @kovetskiy, thanks for opening this issue!

I did some testing and found this also happen in v2.

I'm not sure if this is really a bug or a by design behavior of how variables work (their priority, etc)

I plan to take a look at this before the v3 release, though...

@andreynering andreynering mentioned this issue Jun 1, 2020
18 tasks
@kovetskiy
Copy link
Contributor Author

@andreynering yes, the same on v2, but I thought v3 was going to address this nasty issue. It's very ambiguous to see such behavior.
Imagine my user case: I have a task that creates docker container of an image with specified version and I print a message like:
echo creating docker container with version {{.version}}
I also defined image: "backend/server:{{.version}}" and run something like docker run --name backend-server-{{.version}} {{.image}}
As result I have a message that task is going to create a container of correct version but ends up with an incorrect one.

On the other hand, GNU's make doesn't care about variables' order and just sets variables values to what users have specified.

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

Successfully merging a pull request may close this issue.

3 participants