在当前环境中用点创建环境变量 [英] Create environment variable with dot in the current environment

查看:84
本文介绍了在当前环境中用点创建环境变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道您可以使用命令env创建环境变量.

I know that you can create environment variables with the command env.

例如:

env A.B=D bash

问题在于env是必需的命令,因此创建了一个新的子进程.

The problem is for env a command is required thus creating a new subprocess.

推荐答案

Bash不允许名称中带有非字母数字字符的环境变量( _ 除外).尽管环境中可能包含诸如A.B=D之类的行,但并不要求shell能够使用它,而bash则不能.其他外壳可能会更灵活.

Bash does not allow environment variables with non-alphanumeric characters in their names (aside from _). While the environment may contain a line such as A.B=D, there is no requirement that a shell be able to make use of it, and bash will not. Other shells may be more flexible.

不鼓励使用奇数环境变量的实用程序,但可能存在某些实用程序.您将需要使用env创建这样的环境变量.您可以使用exec env bash避免该子流程,但不会在时间或资源上节省很多.

Utilities which make use of oddly-named environment variables are discouraged, but some may exist. You will need to use env to create such an environment variable. You could avoid the subprocess with exec env bash but it won't save you much in the way of time or resources.

这篇关于在当前环境中用点创建环境变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆