diff options
author | Ville Skyttä <ville.skytta@iki.fi> | 2009-11-20 22:54:44 +0200 |
---|---|---|
committer | Ville Skyttä <ville.skytta@iki.fi> | 2009-11-20 22:54:44 +0200 |
commit | 08c51bccbd367c63373d60a063f8768de4fdb8a6 (patch) | |
tree | 4f8c481518f0c16999467f63659a6b0ff6a796ef /doc | |
parent | 2a506ec3f7a7eadb142def0ff387d9185b60b46a (diff) | |
download | bash-completion-08c51bccbd367c63373d60a063f8768de4fdb8a6.tar.gz |
Add style guide items for case label globbing and [[ ]] vs [ ].
Diffstat (limited to 'doc')
-rw-r--r-- | doc/styleguide.txt | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/doc/styleguide.txt b/doc/styleguide.txt index 12efec38..69209c31 100644 --- a/doc/styleguide.txt +++ b/doc/styleguide.txt @@ -11,17 +11,29 @@ Indentation ----------- Indent step should be 4 spaces, no tabs. +Globbing in case labels +----------------------- + +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, and is concise enough. + +[[ ]] vs [ ] +------------ + +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. + ///////////////////////////////////////// case/esac vs if --------------- -simple matching vs extended globbing ------------------------------------- -in case statements: -@(a|b)) vs -a|-b) - -testing with [[ ]] vs [ ] -------------------------- - line wrapping ------------- |