task icon indicating copy to clipboard operation
task copied to clipboard

`dir` not set when using environment variables

Open yonas opened this issue 1 year ago • 0 comments

This fails to report inside dir /tmp/b:

> mkdir /tmp/{a,b}
> cd /tmp/a
> task -v
task: [/tmp/a] Not found - Using alternative (Taskfile.yaml)
task: "default" started
task: [default] echo tmpdir = $TMP
tmpdir = /tmp/b
task: [default] echo inside dir $PWD
inside dir /tmp/a
task: "default" finished

Taskfile.yaml

version: '3'

dotenv: [.env]

vars:
  tmpdir: $TMP

tasks:

  default:
    dir: "{{ .tmpdir }}"
    cmds:
      - echo tmpdir = {{ .tmpdir }}
      - echo inside dir $PWD

.env

TMP=/tmp/b

https://github.com/go-task/task/issues/1838 is similar but in this case, I'm using absolute paths.

I also noticed that if I try:

...
vars:
  tmpdir:
    sh: echo $TMP
...

The value of $TMP is not copied into the tmpdir variable.

yonas avatar Oct 05 '24 11:10 yonas