Is double square brackets [[ ]] preferable over single square brackets [ ] in Bash?

前端 未结 9 2069
情话喂你
情话喂你 2020-11-22 03:58

A co-worker claimed recently in a code review that the [[ ]] construct is to be preferred over [ ] in constructs like

if [ \"`id -         


        
9条回答
  •  时光说笑
    2020-11-22 04:45

    A typical situation where you cannot use [[ is in an autotools configure.ac script, there brackets has a special and different meaning, so you will have to use test instead of [ or [[ -- Note that test and [ are the same program.

提交回复
热议问题