Skip to content

Variables declared under vars are exported into the environment of sh: (dynamic variable) #2993

Description

@eitsupi

Description

Variables declared under vars are exported into the environment of sh: (dynamic variable) commands, but not into cmds, status or preconditions.
The behaviour is undocumented.

vars and env are documented as separate concepts, so I expected MY_VAR not to be in the environment at all.
Or, if it is exported, to be exported consistently in both places.

Version

3.53.1

Operating system

Linux

Experiments Enabled

No response

Example Taskfile

version: '3'

vars:
  MY_VAR: leaked

tasks:
  default:
    silent: true
    vars:
      FROM_SH:
        sh: 'echo "MY_VAR=$MY_VAR"'
    cmds:
      - 'echo "dynamic var (sh:) sees {{.FROM_SH}}"'
      - 'echo "cmds sees          MY_VAR=$MY_VAR"'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions