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

strange syntax error, only difference is a space. #1493

Closed
bayeslearner opened this issue Feb 3, 2024 · 2 comments
Closed

strange syntax error, only difference is a space. #1493

bayeslearner opened this issue Feb 3, 2024 · 2 comments

Comments

@bayeslearner
Copy link

switch_context:
  desc: "Switch to a different context."
  vars:
    NEW_CONTEXT_NAME: "{{.NEW_CONTEXT_NAME | default ``}}"
  cmds:
    - echo 'Switching to context:' '{{.NEW_CONTEXT_NAME}}' 
    - echo 'Switching to context:{{.NEW_CONTEXT_NAME}}'  
    - echo 'Switching to context: {{.NEW_CONTEXT_NAME}}'  
    - sed -i.bak 's/^export CONTEXT_NAME=.*/export CONTEXT_NAME="{{.NEW_CONTEXT_NAME}}"/' "{{.ROOT_DIR}}/.envrc.context"
    - rm "{{.ROOT_DIR}}/.envrc.context.bak"
    - direnv allow "{{.ROOT_DIR}}"

The third echo will cause syntax errors. Why?

@task-bot task-bot added the state: needs triage Waiting to be triaged by a maintainer. label Feb 3, 2024
@trulede
Copy link

trulede commented Mar 31, 2024

The sequence ": " seems to be interpreted as a YAML Map which contradicts the Taskfile schema (where commands should be a string). The following work:

version: '3'

tasks:
  
  foo:
    vars:
      BAR: '{{.BAR | default "foo"}}'
    cmds:
      - echo {{.BAR}}
      - echo 'message:{{.BAR}}'
      - echo message:\ {{.BAR}}
      - echo 'message:\ {{.BAR}}'
      - "echo message: {{.BAR}}"
      - |
        echo message: {{.BAR}}
      - >
        echo message: {{.BAR}}

I guess that is your problem.

@vmaerten
Copy link
Member

@trulede is right!

@task-bot task-bot removed the state: needs triage Waiting to be triaged by a maintainer. label May 19, 2024
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