Skip to content

Overhaul pass: robustness, readability, and docs#172

Merged
kvz merged 27 commits into
mainfrom
maintainer/overhaul-pass-1
Mar 3, 2026
Merged

Overhaul pass: robustness, readability, and docs#172
kvz merged 27 commits into
mainfrom
maintainer/overhaul-pass-1

Conversation

@kvz

@kvz kvz commented Mar 3, 2026

Copy link
Copy Markdown
Owner

Why

b3bp's docs had grown organically over the years — README was 374 lines mixing contributor instructions with user guidance, Design Principles lived in their own section but duplicated FAQ content, and main.sh had accumulated formatting inconsistencies and stale comments. The src/ libraries also had strict-mode and error-handling gaps that could bite users who source them.

This pass tightens the project across code, tests, and docs while staying true to b3bp's mission: a delete-key friendly, Bash 3+ portable starter template.

What changed

main.sh — the core template

  • Parser robustness: long-option edge cases now fail clearly (unknown --flag, missing values, invalid --flag=value on boolean options)
  • Readability: consolidated 8 individual # shellcheck disable comments into one declaration block, broke dense color-detection conditional across multiple lines, fixed inconsistent indentation in __b3bp_err_report
  • Comments: improved pipefail explanation (frames mysqldump | gzip as a real-life example), clarified set +o nounset reason, added ;true pattern explanation on log functions

src/ libraries

  • parse_url.sh: rewritten to be strict-mode-safe without grep pipelines
  • ini_val.sh, megamount.sh, templater.sh: scoped strict mode to function execution via subshell bodies so sourcing scripts don't have their shell options mutated; templater errors now go to stderr

Documentation

  • README.md (374 → 188 lines): trimmed to user-facing essentials. Coding style reads as recommendations to the consuming developer, not internal rules. Removed sections that had been absorbed elsewhere (Design Principles, Testing, Release Checklist, Migration Guide, Next-Level Roadmap)
  • CONTRIBUTING.md (new): consolidated contributor-facing content — test commands, CI matrix description, CI-enforced coding standards, release instructions with automated gate
  • FAQ.md: enriched the entrypoint-vs-library answer with strict-mode scoping and exit semantics; updated contribution pointer to CONTRIBUTING.md

Testing

  • New acceptance scenarios: main-longopt-errors, main-logging-contracts, parse_url-robust, parse_url-strict, ini_val-robust, templater-robust
  • Docker Bash 3.2.57 lane: test/bash3-docker.sh runs the full suite against Alpine bash:3.2.57, catching portability issues that modern Bash hides
  • Release gate: test/release-ready.sh checks branch, clean tree, green CI, and CHANGELOG state before tagging
  • CI matrix: Linux + macOS + Docker Bash 3.2.57
  • Fast lane: yarn test:fast runs contract-focused subset for quick feedback

Housekeeping

  • Removed stale Travis CI artifacts from test/acceptance.sh
  • Fixed typo in main.sh (increcemntincrement)
  • Removed stale ./deploy.sh reference in acceptance.sh usage comment
  • Style linter now processes all .sh files and catches more issues

Validation

All lanes green:

  • yarn lint:shellcheck (warning severity)
  • yarn lint:style
  • yarn test (full acceptance suite)
  • yarn test:fast (contract subset)
  • yarn test:bash3:docker (Bash 3.2.57)

kvz and others added 25 commits March 3, 2026 09:51
- README: remove Next-Level Roadmap, Migration Guide, Behavior Contracts
  section; fold parser/logging guarantees into Features, fold style rules
  into Coding Style with CI-enforced note (374 → 256 lines)
- main.sh: remove unused __invocation variable, fix "increcemnt" typo,
  add comments explaining ; true log pattern and NO_COLOR detection
- src/templater.sh: send error messages to stderr
- test/acceptance.sh: fix stale deploy.sh comment, remove Travis-specific
  sed patterns
- example.sh: clarify duplicated sections are intentional overrides
- repodocs/overhaul.md: condense iteration log to summary

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Script archetypes, strict mode, exit semantics → FAQ entrypoint/library answer
- Function packaging, export -f → already in Best Practices and FAQ
- Parser as contract → already in Features
- Portability boundary → already in FAQ portability answer
- Compatibility matrix → folded into Testing section
- Remove Design Principles section and TOC entry

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Move Testing, Release Checklist, and CI-enforced coding standards
  to new CONTRIBUTING.md
- Rephrase README coding style as recommendations for consuming devs
  (ShellCheck as suggestion, not CI rule)
- Simplify Best Practices intro
- Point FAQ "How can I contribute" to CONTRIBUTING.md
- README 236 → 188 lines: now fully consumer-facing

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Consolidate 8 shellcheck SC2034 disables into single declaration block
- Break up dense color-detection conditional across multiple lines
- Fix __b3bp_err_report: consistent 2-space indent, function keyword,
  quoted and braced exit "${error_code}"
- Simplify repeatable arg display: remove fragile declare -p|grep
  pattern in favor of direct array iteration
- Reword pipefail comment to explain the real-life example
- Clarify set +o nounset comment (getopts/OPTARG reference)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@kvz kvz changed the title Overhaul parser robustness, strict-mode safety, and CI coverage Overhaul pass: robustness, readability, and docs Mar 3, 2026
Add test/shfmt.sh that installs shfmt v3.12.0 idempotently and supports
lint and fix modes. Wire into package.json as yarn lint:shfmt / fix:shfmt.
CI picks it up automatically via the existing npm-run-all 'lint:**' pattern.

Config: shfmt -i 2 -bn (2-space indent, binary ops may start a line).

Apply shfmt formatting across all .sh files. Key style changes:
- function foo() instead of function foo ()
- one statement per line
- no double blank lines between sections
- spaces in arithmetic: $((OPTIND - 1))
- done <<<"..." (no space before heredoc)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@kvz
kvz marked this pull request as ready for review March 3, 2026 14:05
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@kvz
kvz merged commit a5c3ce5 into main Mar 3, 2026
3 checks passed
@kvz
kvz deleted the maintainer/overhaul-pass-1 branch March 3, 2026 14:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant