elves/elvish

More ergonomic temporary environment variable assignment

tesujimath opened this issue · 2 comments

What new feature should Elvish have?

Running a subprocess with temporary environment variable setting is a very useful feature of bash.

It would be lovely if Elvish had something as ergonomic.

aya> cat print-a.sh
#!/usr/bin/env bash

echo $A

Setup with Elvish:

aya> set-env A old
aya> ./print-a.sh
old

Using bash:

aya> bash
aya$ ./print-a.sh
old
aya$ A=new ./print-a.sh
new

Using Elvish, this is pretty clumsy:

aya> var old_A = $E:A ; set-env A new ; ./print-a.sh ; set-env A $old_A
new
aya> ./print-a.sh
old

Output of "elvish -version"

0.20.1

Code of Conduct

xiaq commented

Use with:

with E:A = new { ... }

Ah, thanks, that is indeed lovely! I just had to upgrade to Elvish 0.21.0.

Thanks for continuing to make Elvish awesome! ❤️