取消设置单个命令的环境变量 [英] Unset an environment variable for a single command

查看:145
本文介绍了取消设置单个命令的环境变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  FOO = bar somecommand 

如果我们想要为单个命令设置变量,该怎么办?

解决方案

技术上,直到某人导出为止,它们不是环境变量。但是你至少可以将它们设置为空:

  FOO =某些命令
/ pre>

如果从环境中删除它们就足够了,可以使用 env

  env -u FOO somecommand 


In Bash, we can set an environment variable for a single command this way:

FOO=bar somecommand

What if we want to unset a variable for a single command?

解决方案

Technically, they're not environment variables until someone exports them. But you can at least set them to empty:

FOO= some command

If removing them from the environment is enough, you can use env:

env -u FOO somecommand

这篇关于取消设置单个命令的环境变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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