我想做什么
$ echo $USERNAME
myusername
$ export USERNAME=newvalue
$ echo $USERNAME
newvalue发生了什么
$ echo $USERNAME
myusername
$ export USERNAME=newvalue
$ echo $USERNAME
myusername我试过什么
sudo .;unset USERNAME。有用注释
zsh我在这一期之前做了什么,
我能够使用direnv (https://github.com/direnv/direnv)多次更改我的环境变量,一切都运行良好。
我能够在.envrc中设置本地env变量。然后我遇到了这个问题..。
溶液
https://unix.stackexchange.com/questions/483469/cannot-change-the-environment-variable
发布于 2018-11-30 21:46:22
在zsh中,USERNAME变量是神奇的。它不是正常导出的env var。从手册页:
USERNAME <S>
The username corresponding to the real user ID of the shell process. If you
have sufficient privileges, you may change the username (and also the user
ID and group ID) of the shell by assigning to this parameter. Also (assum-
ing sufficient privileges), you may start a single command under a different
username (and user ID and group ID) by `(USERNAME=username; command)'在其他shell中,比如bash和fish,这不是一个特殊的var,您可以像任何其他env一样设置它:
bash$ echo $USERNAME
bash$ export USERNAME=wtf
bash$ echo $USERNAME
wtfhttps://stackoverflow.com/questions/53418303
复制相似问题