如何只为脚本运行期间设置环境变量? [英] How to set an environment variable only for the duration of the script?

查看:327
本文介绍了如何只为脚本运行期间设置环境变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Linux(Ubuntu的11.04)在bash,是否有可能临时设置环境变量,将只能从该脚本运行期间正常的变量有什么不同?例如,在一个shell脚本,制作一个应用程序,按HOME暂时设置在present中的文件夹目录,然后运行该应用程序保存到家用便携。


解决方案

  ENV VAR =值myScript的ARGS ...

On Linux (Ubuntu 11.04) in bash, is it possible to temporarily set an environment variable that will only be different from the normal variable for the duration of the script? For example, in a shell script, making an app that saves to HOME portable by temporarily setting HOME to a folder in the present working directory, and then launching the app.

解决方案

env VAR=value myScript args ...

这篇关于如何只为脚本运行期间设置环境变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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