task
task copied to clipboard
Environment variables cannot reference other environment variables
Description
After creating this Taskfile.yml:
version: "3"
env: { FOO: foo }
tasks:
print_foobar:
env: { FOOBAR: { sh: echo "$FOO"bar } }
cmd: echo "$FOOBAR"
and running task print_foobar, I get the output:
task: [print_foobar] echo "$FOOBAR" bar
when I was expecting
task: [print_foobar] echo "$FOOBAR" foobar
Version
3.39.2
Operating system
NixOS
Experiments Enabled
None
Example Taskfile
version: "3"
env: { FOO: foo }
tasks:
print_foobar:
env: { FOOBAR: { sh: echo "$FOO"bar } }
cmd: echo "$FOOBAR"
Another taskfile example
version: "3"
dotenv:
- .env
env:
PORT: {{$PORT | default: 8080}}
tasks:
echo:
cmd: echo $PORT
Expected behavior
If .env contains PORT=9999
task: [echo] echo $PORT
9999
If .env contains nothing
task: [echo] echo $PORT
8080
@bravely-beep This seems to work as you expect with the latest versions of Task.
@CodeTroopers The condition you observe is very likely a duplicate of the issues resolved by #2288 or #2403.