[Bash-completion-devel] Style proposals: case labels and [[ ]]

Ville Skyttä ville.skytta at iki.fi
Wed Nov 4 22:19:26 UTC 2009


Hello,

I'd like to propose two coding style guidelines:

1) Avoid fancy globbing in case labels, just use traditional style when 
possible.  For example, do "--foo|--bar)" instead of "--@(foo|bar))".  
Rationale: the former is easier to read, often easier to grep, and doesn't 
confuse editors as bad as the latter (in my case GNU Emacs), and is concise 
enough.

2) Use [[ ]] instead of [ ] when testing multiple conditions ([ ] is fine for 
single conditions where the syntax works).  Rationale: [[ ]] has short circuit 
behavior within one test containing multiple conditions separated by && or ||, 
while [ ] with -a or -o does not.  Thus it can be more efficient in some cases 
and may reduce need for nesting conditions, and it's cleaner to write for 
example [[ ... && ... ]] than [ ... ] &&  [ ... ], and in general [[ ]] has 
more features.  (I wouldn't be opposed to a guideline always preferring [[ ]] 
over [ ], multiple conditions inside it or not.)



More information about the Bash-completion-devel mailing list