Skip to content

Invalid keys in command when using colon (:) or shart (#) in echo statement #2376

@fabarea

Description

@fabarea

Summary

Task-go fails to parse a Taskfile.yml when the echo command contains certain special characters like colons (:) or hash symbols (#) in the string, throwing parsing errors.

Steps to Reproduce

Case 1: Colon in echo string

  1. Create a Taskfile.yml with the following content:
version: '3'

tasks:
  default:
    desc: Affiche Hello World
    silent: true
    cmds:
      - echo "Say: Hello World"
  1. Run task command. Notice the problematic ":" - Replace "Say:" by "Say"

Case 2: Hash symbol in echo string

  1. Create a Taskfile.yml with the following content:
version: '3'

tasks:
  default:
    desc: Affiche Hello World
    silent: true
    cmds:
      - echo "# Hello World"
  1. Run task command

Case 3: Hash symbol with spaces in echo string

  1. Create a Taskfile.yml with the following content:
version: '3'

tasks:
  default:
    desc: Affiche Hello World
    silent: true
    cmds:
      - echo "  # Hello World"
  1. Run task command

Expected Behavior

The task should execute successfully and output the respective strings:

  • Case 1: "Say: Hello World"
  • Case 2: "# Hello World"
  • Case 3: " # Hello World"

Actual Behavior

Case 1: Colon in echo string

err:  invalid keys in command
file: /home/k6r2j9/work/hacks/infra/benchmark/debug/Taskfile.yml:8:9
  6 |     silent: true
  7 |     cmds:
> 8 |       - echo "Say: Hello World"
    |         ^

Case 2: Hash symbol in echo string

task: Failed to run task "default": 1:6: reached EOF without closing quote "

Case 3: Hash symbol with spaces in echo string

task: Failed to run task "default": 1:6: reached EOF without closing quote "

Additional Information

  • The issue appears to be related to YAML parsing where special characters are being incorrectly interpreted
  • Colons (:) cause "invalid keys in command" errors, suggesting YAML parsing issues
  • Hash symbols (#) cause "reached EOF without closing quote" errors, suggesting quote parsing issues
  • This affects any echo command containing these special characters in the string
  • The error messages suggest both YAML parsing and quote parsing problems

Impact

This bug prevents users from using common special characters like colons (:) and hash symbols (#) in echo statements within Taskfile.yml.

Version

3.44.1

Operating system

Linux 6.8.0-60-generic

Experiments Enabled

No response

Example Taskfile

Metadata

Metadata

Assignees

No one assigned

    Labels

    state: working as intendedThe issue described is working as originally intended.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions