From e3da6ea5e67691add5fac122836c6e0c80725e15 Mon Sep 17 00:00:00 2001 From: fiftydinar <65243233+fiftydinar@users.noreply.github.com> Date: Tue, 1 Oct 2024 14:36:44 +0200 Subject: [PATCH] docs: Clarify `readonly` scenario a bit more --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ba93d0d..049f8c5 100644 --- a/README.md +++ b/README.md @@ -19,9 +19,10 @@ These are general guidelines for writing official bash modules and their documen - Echo what you're doing on each step and on errors to help debugging. - Implement error-checks for scenarios where the image-maintainer might misconfigure the module. - Use `snake_case` for functions and variables changed by the code. - You can utilize `readonly (-f) snake_case` to mark variable or function as read-only when it won't be changed anymore. + You can utilize `readonly (-f) snake_case` to mark variable or function as read-only when it won't be changed anymore for safety. - Use `readonly SCREAMING_SNAKE_CASE` for variables that are set once and stay unchanged. -- For functions that are set once and stay unchanged, make a function & in next line set: `readonly -f function_name`. +- For functions that are set once and stay unchanged, make a function & in next line set: + `readonly -f FUNCTION_NAME`. - Use `"${variable_name}"` when you want to expose information from the variable & to ensure that variables are properly parsed as strings. - If you want to insert another regular string as a suffix or prefix to the `"${variable_name}"`, you should do that in this format: `"prefix-${variable_name}-suffix"` - Use `set -euo pipefail` at the start of the script, to ensure that module will fail the image build if error is caught.