Open ccxuy opened 2 months ago
I don't see anything wrong here. LOC
is being set to "tmp" which is then being used as a relative directory in none
. When you add the leading /
, that path becomes absolute instead.
Some more context about what you're trying to do might help.
My bad, I posted a wrong example. Sorry for that, and I have update the original post. The bug is sub-task's dir creates a new sub-folder and execute on that new sub-folder, but location is set to /tmp
version: '3'
vars:
LOC: "/tmp"
tasks:
test:
dir: "{{.LOC}}/a"
vars:
a:
sh: "echo 1 |grep 1"
cmds:
- echo "dir is {{.LOC}}"
- pwd
> task test
task: Command "echo 1 |grep 1" failed: chdir /a: no such file or directory
Failed at 55: task test
Also, if use sh for variable also behave buggy, looks like the grep command somehow affecte the location, which should be /tmp/a
instead of /a
I'm having the same issue:
> 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
Task version: Task version: v3.38.0 (h1:O7kgA6BfwktXHPrheByQO46p3teKtRuq1EpGnFxNzbo=) Operating system: Ubuntu 2204 Experiments enabled: No
I suppose it should be /tmp? If I change to
dir: "/{{.location}}"
, it become what I expect.also, if I change to:
output is also correct: