-
Deprecation has been temporarily withdrawn, see alpine/tsc#88 This reverts commit 01b9899a.
Deprecation has been temporarily withdrawn, see alpine/tsc#88 This reverts commit 01b9899a.
CODINGSTYLE.md 7.16 KiB
Policy for APKBUILDs
This documents defines a policy for writing APKBUILDs.
Standard selection
APKBUILDs are POSIX shell scripts as defined in POSIX.1-2017 Volume 3. Additionally, the following extensions are supported:
- The
local
keyword for introducing variables local to a function is supported, it is briefly documented in the bash manual. - Non-POSIX parameter extensions
are supported. This includes: Substring expansions (e.g.
${var:offset:length}
) and Replacement expansions (e.g.${var/pattern/string}
). The bash manual contains further information on these two expansions.
NOTE: busybox ash
is currently used to evaluate APKBUILDs - since it
supports additional POSIX shell extensions, your APKBUILD might be
evaluated correctly, even if it is not confirming to this policy
document.
Shell Style Considerations
Formatting
Indention
Indent with tabs, don't use spaces. Avoid whitespaces.
Line Length
Maximum line length is 80 characters, this should be considered a
recommendation and not a strict requirement which must be followed at
all costs. Most notably, automatically generated parts (e.g. by abuild checksum
) are except from this rule.
Compound Statements
Put ; do
and ; then
on the same line as the while
, for
or if
.
Function Declarations
- Always put the function name, the parenthesis and the curly brackets on the same line.
- Don't use spacing between function name and parenthesis.
- Do use spacing between function parenthesis and curly brackets.
Case statement
- Don't indent alternatives.
- A one-line alternative needs a space after the close parenthesis of the pattern and before the
;;
. - End the last case with
;;
.
Variable expansion
- Use
${var}
over$var
only when it is strictly necessary. Meaning: Only if the character following the variable name is an underscore or an alphanumeric character.