[英]bash: variable defining environment variables
In Bash, this work: 在Bash中,这项工作:
FOO=foo BAR=bar a_command
But how to make it works? 但是如何使其起作用?
ENV="FOO=foo BAR=bar"
$ENV a_command
I got: 我有:
FOO=foo: command not found
看看这是否有帮助:
sh -c "$ENV a_command"
This is what the env
command is for 这就是env
命令的用途
env $ENV a_command
Note that the behaviour you see is documented in the manual -- the shell looks for variable assignments before expanding variables. 请注意,您看到的行为已在手册中进行了说明 -外壳在展开变量之前会先查找变量分配。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.