Skip to content

Add example pair for readonly constants (rule 14) #15

Description

@posidoni

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

  1. 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.
  2. 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.
  3. Add a row to the table in examples/standards/README.md.

Verify

task ci

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentationgood first issueGood for newcomers

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions