-
Notifications
You must be signed in to change notification settings - Fork 3
Guideline for one_liners
linux-shell-base edited this page Oct 21, 2017
·
16 revisions
Guideline for one-liners in Linux-shell-base.
- has a description.
- is continued on a single line (for easy maintenance of layout when copying and pasting to a script or terminal).
One-liner files are created in the following format:
(Note: Any section in addition to Description is included if necessary)
# Description
one-liner
# Description
one-liner
# Description
# Note: Note
one-liner
- Any other documentation section is included if necessary.
For an example, see one-liners-output.bash.
- Spaces are used for all whitspace.
- A variable name uses acronyms whenever possible.
- Single quotes are used when possible.
- A non-global variable inside a function is declared local.
- A variable in an arithmetic expression is called without brackets (e.g.
$((numEntries - count))
, not$((${numEntries} - ${count}))
). - An argument variable (e.g.
${1}
) is used directly rather than being assigned to a new variable when possible.
- A single bracket conditional is used when possible.
- A parameter expansion or command substitution is quoted unless otherwise required.
All other code style rules are up to the contributor. They are reviewed however.