why quote removal isn't performed between [[ … ]]?

前端 未结 3 986
感动是毒
感动是毒 2020-12-19 15:24
$ man bash

Word splitting and filename expansion are not performed on the words between the ‘[[’ and ‘]]’; tilde expansion, paramete

3条回答
  •  南笙
    南笙 (楼主)
    2020-12-19 15:45

    [[ ... ]] is not POSIX syntax, but an extension that is found in the Korn shell. Bash does it the way the Korn shell does it, because doing it differently would just be incompatible for no reason.

    From Korn Shell 93 man page:

    Conditional Expressions
    A conditional expression is used with the [[ compound command to test attributes of files     
    and to compare strings. Field splitting and file name generation are not performed on the   
    words between [[ and ]]. Each expression can be constructed from one or more of the    
    following unary or binary expressions: 
    

    http://www2.research.att.com/sw/download/man/man1/ksh.html

    So why does the Korn shell do it that way? 1) Who cares; 2) E-mail Dave Korn. 3) Maybe the answer is found in some document at http://www.kornshell.com . But think about this: if the field splitting and file expansion were performed, how would this construct be different from [ ... ]?

提交回复
热议问题