简体   繁体   English

env 不工作,但 echo 显示变量

[英]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. env不显示变量,但echo正在显示它。

i was routinely testing a.env file import using env | grep VAR我经常使用env | grep VAR env | grep VAR but somehow it did not show right after i sourced it. env | grep VAR但不知何故在我采购它后它没有立即显示。 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.我有 oh-my-zsh 的 zsh。 don't have any dotenv plugins enabled.没有启用任何 dotenv 插件。 would appreciate any help.将不胜感激任何帮助。 i am in kubuntu 20.04.我在 kubuntu 20.04。

I have also tested this entire setup in xterm.我还在 xterm 中测试了整个设置。 same result.同样的结果。

It's not displayed by env because TARXAN is not an environment variable, ie it has not been exported. env不显示它,因为TARXAN不是环境变量,即它没有被导出。 It's a shell variable only.它只是一个 shell 变量。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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