Context
reference/shell-standards.md rule 14
("Make constants readonly") has no runnable pair under
examples/standards/ proving it, unlike most of the
other 17 non-negotiables. Follow the contract in
CONTRIBUTING.md.
Plan
- Add
examples/standards/12-readonly-constants.good.sh:
- Declare a value that must never change with
readonly (e.g.
readonly max_retries=3), then use it.
- Self-contained, no arguments, exits 0, clean under
shellcheck --severity=warning and shfmt.
- Add
examples/standards/12-readonly-constants.bad.sh:
- Declare the same "constant" as a plain variable, then reassign it later
in the script (simulating an accidental shadow/typo elsewhere) to show
nothing protects it.
- Safe to run.
# expect-shellcheck: none — ShellCheck has no code for
"this should be readonly"; it's a style-guide-only pitfall.
- Add a row to the table in
examples/standards/README.md.
Verify
must stay green — tools/check-bad-examples.sh asserts the .bad.sh
directive is present, and tests/examples.bats runs the new .good.sh.
A small ask
If you used an AI coding agent for this PR, feel free to say so — add a line
to the PR description like:
Authored by <your name/handle>, implemented using <model name>.
Either way is genuinely welcome here.
Context
reference/shell-standards.mdrule 14("Make constants
readonly") has no runnable pair underexamples/standards/proving it, unlike most of theother 17 non-negotiables. Follow the contract in
CONTRIBUTING.md.
Plan
examples/standards/12-readonly-constants.good.sh:readonly(e.g.readonly max_retries=3), then use it.shellcheck --severity=warningandshfmt.examples/standards/12-readonly-constants.bad.sh:in the script (simulating an accidental shadow/typo elsewhere) to show
nothing protects it.
# expect-shellcheck: none— ShellCheck has no code for"this should be readonly"; it's a style-guide-only pitfall.
examples/standards/README.md.Verify
must stay green —
tools/check-bad-examples.shasserts the.bad.shdirective is present, and
tests/examples.batsruns the new.good.sh.A small ask
If you used an AI coding agent for this PR, feel free to say so — add a line
to the PR description like:
Either way is genuinely welcome here.