Skip to content

The 'cat << EOF' produces wrong output when using escaped quotes #1538

@ninlil

Description

@ninlil
  • Task version: v3.35.1
  • Operating system: Ubuntu 20.04
  • Experiments enabled: none

Basic shell command works exactly the same in sh, bash and zsh (i.e producing the exact same output as input)

$ cat << EOF
{
  "key1": "a simple text with an escaped doublequote \" in the text"
}
EOF
{
  "key1": "a simple text with an escaped doublequote \" in the text"
}

but the following task prints different outputs:

version: '3'
tasks:
  test:
    vars:
      TEXT: |
        {
          "key1": "a simple text with an escaped doublequote \" in the text"
        }
    cmds:
      - echo '{{.TEXT}}'
      - |
        cat << EOF
        {{.TEXT}}
        EOF

Output: (do note the last entry not having an escaped doublequote)

$ task test
task: [test] echo '{
  "key1": "a simple text with an escaped doublequote \" in the text"
}
'
{
  "key1": "a simple text with an escaped doublequote \" in the text"
}

task: [test] cat << EOF
{
  "key1": "a simple text with an escaped doublequote \" in the text"
}

EOF

{
  "key1": "a simple text with an escaped doublequote " in the text"
}

I see this as 1 bug and 1 feature-request:

feature suggestion: apart of settings your command using the "sh:" key, add a "stdin" or "input" key to be a variable

    cmds:
      - sh: cat
        stdin: TEXT

Metadata

Metadata

Assignees

No one assigned

    Labels

    dep: mvdan/shIssues related to the upstream interpreter used by Task.

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions