Skip to content

Commit

Permalink
doc/styleguide: establish _comp_ prefix for our functions
Browse files Browse the repository at this point in the history
  • Loading branch information
scop committed Dec 21, 2020
1 parent 53bb35a commit 822d113
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions doc/styleguide.txt
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,20 @@ name typically based on array name but in singular when looping over actual
values. If an index or value is to be accessed later on instead of being just
locally for looping, use a more descriptive and specific name for it.

Function names
--------------

Use the _comp_ prefix for all function names, and _comp_cmd_ for functions
defined in per command completion files and not anywhere else. Prefixing with
an underscore helps keep the functions out of the way for most command name
completions (except obviously ones starting with an underscore or ones that have
nothing typed in yet), and having a consistent prefix helps avoid some clashes
and gives a hint where a function originates from.

It is known that a lot of functions in the tree do not follow this practice.
This is due to backwards compatibility reasons, but all functions introduced
after version 2.11 should follow this name prefix rule.

/////////////////////////////////////////
case/esac vs if
---------------
Expand All @@ -128,7 +142,7 @@ quoting
awk vs cut for simple cases
---------------------------

variable and function naming
----------------------------
variable naming
---------------

/////////////////////////////////////////

0 comments on commit 822d113

Please # to comment.