LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1015|回复: 2

请教builtin和keyword的区别

[复制链接]
发表于 2005-6-25 15:53:54 | 显示全部楼层 |阅读模式
在看Advanced Bash-Scripting Guide的时候,作者老是说一些命令是builtin(我想是内置命令的意思吧),又说另一些命令是keyword。例如,break和continue是builtin,其它的循环命令如while和case是keyword。
请问它们两者有什么区别?谢谢。
 楼主| 发表于 2005-6-25 16:08:34 | 显示全部楼层
A builtin  is a command contained within the Bash tool set, literally built in. This is either for performance reasons -- builtins execute faster than external commands, which usually require forking off a separate process -- or because a particular builtin needs direct access to the shell internals.
A keyword  is a reserved word, token or operator. Keywords have a special meaning to the shell, and indeed are the building blocks of the shell's syntax. As examples, "for", "while", "do", and "!" are keywords. Similar to a builtin, a keyword is hard-coded into Bash, but unlike a builtin, a keyword is not by itself a command, but part of a larger command structure. [1]
回复 支持 反对

使用道具 举报

发表于 2005-6-25 17:18:54 | 显示全部楼层
builtin是内建的命令,其实就是一些常用的小函数,特点是运行速度要比外部(磁盘上的)命令块,而且是在当前shell进程里运行(不再fork出一个子shell)
keyword不是命令!而是保留字!
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表