在bash:
$ type :
: is a shell builtin
$ type true
true is a shell builtin
看起来它们是相同的,但是它们没有给出相同的系统跟踪:
$ strace :
strace: :: command not found
$ strace true
execve("/bin/true", ["true"], [/* 82 vars */]) = 0
[snip]
exit_group(0) = ?
我尝试了diff strace bash -c : 2>:.txt和strace bash -c true 2>true.txt,但是除了内存位置之外,它们之间没有任何区别。
在dash:
$ type :
: is a special shell builtin
$ type true
true is a shell builtin
好,所以他们不一样。help :并且help true不是很有用,它们在bash和中返回相同的值dash。它们之间是否有任何实际区别,只是:节省了三个字节并使脚本的可读性降低了?
3
有关内置冒号目的的有关问题。
—
2012年