Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2445247
  • 博文数量: 328
  • 博客积分: 4302
  • 博客等级: 上校
  • 技术积分: 5486
  • 用 户 组: 普通用户
  • 注册时间: 2010-07-01 11:14
个人简介

悲剧,绝对的悲剧,悲剧中的悲剧。

文章分类

全部博文(328)

文章存档

2017年(6)

2016年(18)

2015年(28)

2014年(73)

2013年(62)

2012年(58)

2011年(55)

2010年(28)

分类: 系统运维

2011-10-11 10:29:04

.号命令

# .
bash: .: filename argument required
.: usage: . filename [arguments]


一般在执行一个文件的时候,都会启动一个新的子shell来运行,而"."是在当前shell运行程序。这样就造成一个重要的结果,文件中的环境变量保留在当前shell中。

The . command (a.k.a. source) is like an "include" directive. It reads the contents of a file and executes them in the current process ... just as though you had typed them at the prompt. Normally the shell executes (external) commands in subprocesses ... regardless of whether those are shell scripts, or Perl, Python, compiled binaries or whatever. It's only if you source the file that the contents of the file are read and processed by your current shell/process.

Conceptually source is most similar to eval. The difference is that source takes a filename as an argument while eval processes a string (usually a value in some variable). In some ways eval is also confusing because you can often just put a shell variable dereference/expression where you'd put a command and the shell will evaluate that. There are only some odd cases (deferred variable evaluation) where the eval keyword is necessary.   --by Jim Dennis
阅读(2923) | 评论(0) | 转发(0) |
0

上一篇:Perl 时间日期处理

下一篇:zoneadm 命令

给主人留下些什么吧!~~