【发布时间】:2011-03-14 14:01:26
【问题描述】:
一个什么都不做的命令的目的是什么,只不过是一个评论领导者,但实际上是一个内置的shell?
它比每次调用向脚本中插入评论要慢约 40%,这可能因评论的大小而有很大差异。我能看到的唯一可能的原因是:
# poor man's delay function
for ((x=0;x<100000;++x)) ; do : ; done
# inserting comments into string of commands
command ; command ; : we need a comment in here for some reason ; command
# an alias for `true'
while : ; do command ; done
我想我真正在寻找的是它可能具有的历史应用。
【问题讨论】:
-
@Caleb - 我在那之前两年问过这个问题。
-
我不会说返回特定值的命令“什么都不做”。除非函数式编程包含“什么都不做”。 :-)
-
: 'null' 程序的用途之一是注释 Shell 序列。这是 Ken Thompson 在他 1976 年的论文 The Unix Command Language 中所说的。 github.com/susam/tucl/blame/master/…