Skip to content

Task creates spurious brand new directories on disk with backslashes preceding every space #2208

@chimbori

Description

@chimbori

Description

I have a Taskfile in a parent directory, and another Taskfile in a subdirectory of the parent, using the includes syntax.

The file names / directory names contain space characters (on macOS).

When running a task from the from the sub-directory Taskfile, Task ends up creating brand new spurious directories on disk.

Looks like it’s reading the full path, escaping it incorrectly, and then passing it on to os.MkdirAll.

This has the side-effect that Task can no longer find binaries in my chosen directory (./my-binary under USER_WORKING_DIR), because now it’s searching the wrongly-created path instead.

———————————————————————————————————————————————————————————————[ 05:07:55 ]————
/…/BugReports/Taskfile $ tree .
.
└── sub directory with spaces
    ├── sub-sub-directory with spaces
    │   └── Taskfile.yml
    └── Taskfile.yml

3 directories, 2 files
———————————————————————————————————————————————————————————————[ 05:07:57 ]————
/…/BugReports/Taskfile $ cat "sub directory with spaces/Taskfile.yml"
version: '3'

tasks:
  tree-parent:
    desc: tree
    # dir: '{{.USER_WORKING_DIR}}'
    cmds:
      - echo "{{.USER_WORKING_DIR}}"
      - tree .
———————————————————————————————————————————————————————————————[ 05:08:08 ]————
/…/BugReports/Taskfile $ cat "sub directory with spaces/sub-sub-directory with spaces/Taskfile.yml"
version: '3'

includes:
  parents:
    taskfile: ..
    flatten: true

tasks:
  tree-subdir:
    desc: tree
    cmds:
      - tree .
———————————————————————————————————————————————————————————————[ 05:08:16 ]————
/…/BugReports/Taskfile $ cd "sub directory with spaces/sub-sub-directory with spaces"
———————————————————————————————————————————————————————————————[ 05:08:32 ]————
/…/BugReports/Taskfile/sub directory with spaces/sub-sub-directory with spaces $ t tree-parent
task: [tree-parent] echo "/…/BugReports/Taskfile/sub directory with spaces/sub-sub-directory with spaces"
/…/BugReports/Taskfile/sub directory with spaces/sub-sub-directory with spaces
task: [tree-parent] tree .
.

0 directories, 0 files
———————————————————————————————————————————————————————————————[ 05:08:36 ]————
/…/BugReports/Taskfile/sub directory with spaces/sub-sub-directory with spaces $ cd ../../
———————————————————————————————————————————————————————————————[ 05:08:39 ]————
/…/BugReports/Taskfile $ tree .
.
├── sub directory with spaces
│   ├── sub-sub-directory with spaces
│   │   └── Taskfile.yml
│   └── Taskfile.yml
└── sub\ directory\ with\ spaces
    └── sub-sub-directory\ with\ spaces

5 directories, 2 files
———————————————————————————————————————————————————————————————[ 05:08:41 ]————

Version

3.43.2

Operating system

macOS

Experiments Enabled

No response

Example Taskfile

version: '3'

includes:
  parents:
    taskfile: ..
    flatten: true

tasks:
  tree-subdir:
    desc: tree
    cmds:
      - tree .

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions