2 ms·
How do people use environment variables with powershell? I often want to do `FOO=bar ./program`, but this doesn't seem to be supported. I googled briefly, but t
by throwaway894345 6y ago
How do people use environment variables with powershell? I often want to do `FOO=bar ./program`, but this doesn't seem to be supported. I googled briefly, but there weren't many satisfactory answers.
- majkinetor 6y ago$Env:FOO='bar'; ./program
- brutt 6y agoIt's equivalent of `export FOO='bar'; ./program` , which is not same as `FOO='bar' ./program`, which, in turn, is equivalent to `OLD_FOO="$FOO"; export FOO='bar'; ./program; export FOO="$OLD_FOO";` .
- xfer 6y agothere isn't a directly supported way. you write a function to backup, run and restore the old variable to get the same behaviour. Not very ideal.