diff options
Diffstat (limited to 'doc/styleguide.txt')
-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 ------------- |