moon.sh: a tiny POSIX moon-phase script - #4
Merged
Conversation
A small, dependency-free flourish: `./moon.sh` prints the current phase of the Moon (emoji + name + age in days), computed with integer arithmetic from a known new-moon reference and the synodic month. Pure POSIX sh, shellcheck clean, and deliberately standalone — it is not wired into install.sh. An optional epoch-seconds argument makes it fully testable; tests/moon.bats pins every named phase plus the help and input-validation paths and runs under dash. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016jGCQzWMQD3sBBbcvZtLyQ
Broaden the two hard-coded paths (`shellcheck install.sh`, `bats tests/install.bats`) to globs so new scripts and test files are covered automatically — the same derive-don't-hand-maintain property install.sh already has for its copy list. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016jGCQzWMQD3sBBbcvZtLyQ
testtest126
marked this pull request as ready for review
July 14, 2026 16:23
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
A small, dependency-free flourish for the repo:
./moon.shprints the current phase of the Moon — emoji + name + age in days.It's deliberately standalone — not wired into
install.sh, and not added undertemplates/— so it doesn't change what the kit installs.How it works
EPOCH_SECONDSargument makes "now" injectable, which is what makes it deterministically testable and lets you check any date, not just today.--help, unknown-option rejection, and non-numeric-input rejection mirror the argument-handling style already ininstall.sh.Conventions followed
sh(#!/usr/bin/env sh,set -eu, no bashisms) — passesshellcheckclean and runs underdash.tests/moon.batspins every named phase, the age output, both error paths,--help, the pre-reference-timestamp guard, and a strict-POSIX (dash) run.CI
The workflow hard-coded
shellcheck install.shandbats tests/install.bats, which would have left the new files unchecked. Broadened both to globs (./*.sh,tests/*.bats) so scripts and test files are picked up automatically — the same derive-don't-hand-maintain propertyinstall.shalready has for its copy list.Verification
shellcheck ./*.sh→ cleanbats tests/*.bats→ 22/22 pass (10 install + 12 moon)./moon.shfor real across new / first-quarter / full / waning-gibbous / last-quarter reference points, the default (today), the error paths, and underdash.🤖 Generated with Claude Code
Generated by Claude Code