简体   繁体   中英

env is not working but echo displays the variables

Completely perplexed at this behaviour.

env is not displaying the variable but echo is displaying it.

i was routinely testing a.env file import using env | grep VAR env | grep VAR but somehow it did not show right after i sourced it. that got me thinking.

Here are the steps i am using to get the problem.

$ cat >.env
TARXAN=wat
^D
$ . .env
$ echo $TARXAN
wat
$ env | grep TARXAN

$

i have zsh with oh-my-zsh. don't have any dotenv plugins enabled. would appreciate any help. i am in kubuntu 20.04.

I have also tested this entire setup in xterm. same result.

It's not displayed by env because TARXAN is not an environment variable, ie it has not been exported. It's a shell variable only.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM