2021年2月17日(水) 1:52 Oğuz <oguzismailuy...@gmail.com>: > They resemble `[ ... ]' (I know it's a simple command, but still), maybe > that's why. I think it'd seem more inconsistent to ordinary user if > > if [[ x ]] then [[ x ]] fi > > worked but > > if [ x ] then [ x ] fi > > didn't.
``Ordinary users'' may consider it being inconsistent, but what would you think of this? Actually, as you have written, [ ... ] is a simple command, so there are already many differences that ``ordinary users'' would think inconsistent. For example, the word splitting and pathname expansion rules are different. For another example, `tempenv=1 [[ -v tempenv ]]' is disallowed while `tempenv=1 [ -v tempenv ]' is allowed. and more... Letting [[ ... ]] behave differently from either of [ ... ] and ( ... ) means that we create the third category of command which grammatically behaves like neither the simple command nor the compound command. I actually feel it is more consistent to allow `if [[ ... ]] then' as far as we accept `if ( ... ) then'. That would be the only neat thing under the POSIX constraints. -- Koichi