Skip to content

test Command Produces Unexpected Results #1975

@ic-it

Description

@ic-it

Description

Problem Description:
The test and [ ] commands produce inconsistent results when executed via a Taskfile compared to direct execution in the shell.


$ echo $SHELL
/bin/bash
$ task --version
Task version: v3.40.1 (h1:Q/TjPh5SAI+XK2fBravDPZXNGm6mvnwrLJqCXfhZ3Wc=)
$ task test
task: [test] test -w .ruff_cache && echo WRITABLE || echo NOT WRITABLE
NOT WRITABLE
task: [test] [ -w .ruff_cache ] && echo WRITABLE || echo NOT WRITABLE
NOT WRITABLE
$ test -w .ruff_cache && echo WRITABLE || echo NOT WRITABLE
WRITABLE
$ [ -w .ruff_cache ] && echo WRITABLE || echo NOT WRITABLE
WRITABLE

Version

v3.40.1

Operating system

Linux, Fedora 41

Experiments Enabled

No response

Example Taskfile

version: 3

tasks:
  test:
    cmds:
      - test -w .ruff_cache && echo WRITABLE || echo NOT WRITABLE
      - |
        [ -w .ruff_cache ] && echo WRITABLE || echo NOT WRITABLE

Dependency

This issue depends on mvdan/sh#1116

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