BASH:是"出口"需要时,设置在.bashrc中的变量是什么时候? [英] BASH: Is "export" needed, when setting a variable in .bashrc?

查看:142
本文介绍了BASH:是"出口"需要时,设置在.bashrc中的变量是什么时候?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道是否有需要在.bashrc里设置变量时,使用出口。

I wonder if there is a need to use "export" when setting a variable in .bashrc.

在我的测试中编辑的.bashrc有

In my tests editing .bashrc there was no difference between

foo=bar

export foo=bar

在这两种情况下,登录后回声$ foo的产出栏。

In both cases, after login "echo $foo" outputs "bar".

我使用Debian挤压,如果该事项。

I am using Debian Squeeze, if that matters.

感谢你们在前进。

推荐答案

尝试创建一个访问变量的shell脚本。

Try creating a shell script that accesses the foo variable.

如果导出版,这将是在shell脚本中可见的,否则也不会

If foo was export'ed, it will be visible in the shell script, otherwise it won't.

这篇关于BASH:是"出口"需要时,设置在.bashrc中的变量是什么时候?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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