What is the purpose of the : (colon) GNU Bash builtin?

前端 未结 12 863
梦如初夏
梦如初夏 2020-11-22 14:01

What is the purpose of a command that does nothing, being little more than a comment leader, but is actually a shell builtin in and of itself?

It\'s slower than inse

12条回答
  •  旧时难觅i
    2020-11-22 14:16

    I saw this usage in a script and thought it was a good substitute for invoking basename within a script.

    oldIFS=$IFS  
    IFS=/  
    for basetool in $0 ; do : ; done  
    IFS=$oldIFS  
    

    ... this is a replacement for the code: basetool=$(basename $0)

提交回复
热议问题