Skip to content

unzip fails when environment variable UNZIP (uppercase) is set #2264

@t-silvers

Description

@t-silvers

Description

Hi, thanks for your work on Task, it's a great tool. I’m trying to understand some behavior I’ve observed when using Task with unzip. In case I'm missing something obvious, the issue title is a good tldr.

Consider the following Taskfiles. I’ve labeled succeeding tasks as succeeds-* and failing tasks as fails-*. For failing tasks, the error message is unzip: cannot find or open <UNZIP value>, <UNZIP value>.zip or <UNZIP value>.ZIP, where <UNZIP value> is the corresponding value of the UNZIP environment variable. I would expect this error message for unzip "<UNZIP value>".

  1. issue_examples/unzip_task_env/Taskfile.yml

    version: '3'
    
    vars:
      UNZIP: unzip
    
    tasks:
      succeeds-taskvar:
        - unzip -h > /dev/null
        - '{{.UNZIP}} -h > /dev/null'
    
      fails-envvar:
        cmds:
          - $UNZIP -h > /dev/null
        env:
          UNZIP: unzip
    
      fails-envvar-as-taskvar:
        cmds:
          - '{{.UNZIP}} -h > /dev/null'
        env:
          UNZIP: unzip
    
      fails-envvar-abspath:
         cmds:
          - $UNZIP -h > /dev/null
         env:
           UNZIP: /usr/bin/unzip
    
      fails-with-envvar-set:
        cmds:
          - unzip -h > /dev/null
        env:
          UNZIP: unzip
  2. issue_examples/make_counterexample/Taskfile.yml

    version: '3'
    
    vars:
      MAKE: make
    
    tasks:
      succeeds-taskvar:
        - make -h > /dev/null
        - '{{.MAKE}} -h > /dev/null'
        - $MAKE -h > /dev/null
    
      succeeds-envvar:
        cmds:
          - make -h > /dev/null
          - '{{.MAKE}} -h > /dev/null'
          - $MAKE -h > /dev/null
        env:
          MAKE: make
    
  3. issue_examples/unzip_global_env/Taskfile.yml

    version: '3'
    
    env:
      MAKE: make
      UNZIP: unzip
    
    tasks:
      succeeds-make: make -h > /dev/null && {{.MAKE}} -h > /dev/null && $MAKE -h > /dev/null
    
      fails-unzip: unzip -h > /dev/null
    
  4. issue_examples/unzip_global_env_cli/Taskfile.yml

    version: '3'
    
    tasks:
      fails-unzip: echo "{{spew .UNZIP}}" && unzip -h > /dev/null
    

    run using

    $ env UNZIP=unzip task -s -t issue_examples/unzip_global_env_cli/Taskfile.yml fails-unzip
    (string) (len=5) unzip
    
    unzip:  cannot find or open unzip, unzip.zip or unzip.ZIP.
    

    or

    $ env UNZIP=make task -s -t issue_examples/unzip_global_env_cli/Taskfile.yml fails-unzip
    (string) (len=4) make
    
    unzip:  cannot find or open make, make.zip or make.ZIP.
    
  5. issue_examples/unzip_task_env_lowercase/Taskfile.yml

    version: '3'
    
    vars:
      unzip: unzip
    
    tasks:
      succeeds-taskvar:
        - unzip -h > /dev/null
        - '{{.unzip}} -h > /dev/null'
    
      succeeds-envvar:
        cmds:
          - unzip -h > /dev/null
          - '{{.unzip}} -h > /dev/null'
          - $unzip -h > /dev/null
        env:
          unzip: unzip
    

Version

3

Operating system

linux

Experiments Enabled

no

Example Taskfile

see description

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions