Skip to content

Fish completion breaks if task description have colon (:) #2101

@ikura-hamu

Description

@ikura-hamu

Description

Summary

The fish completion is broken when colon exists in task description.

Detail

When task descriptions contain colons (:), the fish shell completion breaks due to incorrect sed scripts. Additionally, sed behaves differently across environments, which further complicates the issue. By using fish scripts instead of sed, we can write more robust and maintainable completion scripts.

Environment:

  • Task version: v3.41.0
  • Fish version: v4.0.0
  • OS: Ubuntu 22.04

Steps to Reproduce

The issue can be reproduced using the following Taskfile.yml:

Taskfile.yml

version: "3"

tasks:
  command:
    desc: "description without a colon."

  colon:
    desc: "description with a colon: description with a colon."

  colon-s:
    desc: "description with a colon: and a following space."

  command:alias:
    desc: "description without a colon, but with aliases."
    aliases:
      - cma
      - cmda

  colon:alias:
    desc: "description with a colon: and aliases."
    aliases:
      - cla
      - clna

  colon-s:alias:
    desc: "description with a colon: a following space, and aliases."
    aliases:
      - clsa
      - clnsa

  no-desc:
    cmd: echo "no description."

  no-desc:alias:
    aliases:
      - nda
      - nda2

  "task with spaces: and a colon":
    desc: "description with spaces."

  "task and desc with spaces: and a colon":
    desc: "description with spaces: and a colon."


Before

Image

  • The completions for colon, colon:alias, colon-s, and colon-s:alias are broken.
  • task and desc with spaces: and a colon is also broken.

After

I attempted to fix the issue in my forked repository:
https://github.com/ikura-hamu/task

Image

  • The completions for colon, colon:alias, colon-s, and colon-s:alias now work correctly.
  • However, task and desc with spaces: and a colon is still broken.
  • Additionally, task with spaces: and a colon is now broken.

Discussion

I believe that tasks with both colons and spaces in their names are rare, as they are inconvenient to type and look somewhat messy in definitions. Therefore, my fix should work well for most users.

Would it be acceptable to merge this fix even though it does not fully resolve the issue for task names containing both spaces and colons? Or would you prefer a more comprehensive solution?

Version

3.41.0

Operating system

Ubuntu 22.04

Experiments Enabled

No response

Example Taskfile

version: "3"

tasks:
  command:
    desc: "description without a colon."

  colon:
    desc: "description with a colon: description with a colon."

  colon-s:
    desc: "description with a colon: and a following space."

  command:alias:
    desc: "description without a colon, but with aliases."
    aliases:
      - cma
      - cmda

  colon:alias:
    desc: "description with a colon: and aliases."
    aliases:
      - cla
      - clna

  colon-s:alias:
    desc: "description with a colon: a following space, and aliases."
    aliases:
      - clsa
      - clnsa

  no-desc:
    cmd: echo "no description."

  no-desc:alias:
    aliases:
      - nda
      - nda2

  "task with spaces: and a colon":
    desc: "description with spaces."

  "task and desc with spaces: and a colon":
    desc: "description with spaces: and a colon."

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: completionsChanges related to shell completions and scripts.

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions