Review code style, refactor functions into namespaces
Original report by Michael Diamond (Bitbucket: dimo414).
Reference https://google.github.io/styleguide/shell.xml
The Google Style Guide suggests using :: to delimit function namespaces, but that prevents tab-completion¹ (perhaps that's an advantage?). . seems to be a common choice which does enable tab-completion.
¹ See Bash FAQ E13 and https://stackoverflow.com/a/12495727
Original comment by Michael Diamond (Bitbucket: dimo414).
There are really a couple different namespaces to support:
__pgem::: truly private, used only internally by ProfileGem (e.g. the functions inprivateGemFunctions.shand other helpers)_pgem_: Utility functions intended to be used by gemspgem_: User-facing functions intended to be called interactively
Original comment by Michael Diamond (Bitbucket: dimo414).
Gems should also have standard namespaces:
__foo_gem::for foo.gem's private fields_foo_gem_for fields that will be accessed by other gems- User-facing functions and variables should not be namespaced
Original comment by Michael Diamond (Bitbucket: dimo414).
Different plan, along the lines of bash-cache:
pg::_foofor private helper functionspg::foofor non-interactive functions such as those used by gemspgem_foofor user-facing functions
Gems should similarly use a bar:: namespace (where "bar" is the name of the gem) for non-user-facing functions.
NB pg is a standard Unix command, so pg shouldn't be used directly.