请问(冒号)GNU Bash内置的目的是什么?

(冒号)GNU Bash内置的目的是什么?

一个命令的目的是什么,它什么也不做,只是一个评论领导者,但实际上它本身就是一个shell内置的东西?

它比在脚本中插入注释的速度慢,每次调用的速度大约为40%,这可能取决于评论的大小而有很大的差异。我能看到的唯一原因是:

# poor man's delay functionfor ((x=0;x<100000;++x)) ; do : ; done# inserting comments into string of commandscommand ;
 command ; : we need a comment in here for some reason ; command# an alias for `true' (lazy programming)while : ; do command ; done

我想我真正想要的是它可能有什么样的历史应用程序。



人到中年有点甜
浏览 471回答 3
3回答

弑天下

我使用它轻松地启用/禁用变量命令:#!/bin/bashif&nbsp;[[&nbsp;"$VERBOSE"&nbsp;==&nbsp;""&nbsp;||&nbsp;"$VERBOSE"&nbsp;==&nbsp;"0"&nbsp;]];&nbsp;then &nbsp;&nbsp;&nbsp;&nbsp;vecho=":"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;no&nbsp;"verbose&nbsp;echo"else &nbsp;&nbsp;&nbsp;&nbsp;vecho=echo&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;enable&nbsp;"verbose&nbsp;echo"fi$vecho&nbsp;"Verbose&nbsp;echo&nbsp;is&nbsp;ON"因此$&nbsp;./vecho $&nbsp;VERBOSE=1&nbsp;./vechoVerbose&nbsp;echo&nbsp;is&nbsp;ON这就形成了一个干净的脚本。这不能用“#”来完成。还有,:&nbsp;>afile是保证“afile”存在但长度为0的最简单方法之一。
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JQuery