Skip to content

Commit

Permalink
docs: Some more refinements to readonly
Browse files Browse the repository at this point in the history
  • Loading branch information
fiftydinar authored Oct 1, 2024
1 parent e3da6ea commit 1570473
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@ 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 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`.
`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.
Expand Down

0 comments on commit 1570473

Please sign in to comment.