Skip to content

chore: broaden AfterBuild.sh portability#87

Merged
SolAstrius merged 1 commit into
TeaGuild:mainfrom
jonpepler:telemachus/afterbuild-macos
May 11, 2026
Merged

chore: broaden AfterBuild.sh portability#87
SolAstrius merged 1 commit into
TeaGuild:mainfrom
jonpepler:telemachus/afterbuild-macos

Conversation

@jonpepler
Copy link
Copy Markdown
Contributor

@jonpepler jonpepler commented May 11, 2026

⚠️ I've used Claude to make this change and draft most of the description below. Built, tested locally in KSP, and happy with the result, so sharing here.

Summary

Two small tweaks to Telemachus/AfterBuild.sh so the post-build step runs cleanly under a wider range of bash versions and coreutils variants. Behaviour-preserving on the existing build path.

Changes

  1. Possibly-empty array expansion under set -u"${authHeader[@]}" errors on older bash versions when the array is empty. ${authHeader[@]+"${authHeader[@]}"} is the portable equivalent that expands to nothing in the empty case and works on both old and current bash. Same observable behaviour when GITHUB_TOKEN is set.

  2. cp -pR instead of cp -ra-a is a GNU shorthand for -dR --preserve=all that BSD cp doesn't accept in the combined short form. cp -pR is POSIX-compliant, preserves modes + timestamps (the bits the previous -a preserved that the build actually cares about), and works under both GNU and BSD coreutils. Recursive copy semantics are unchanged.

Validation

Tested locally on macOS (bash 3.2 / BSD coreutils):

  • dotnet build -c Release completes successfully; publish/api-schema.json is regenerated and contains the same entry shapes as before.
  • The release-staged publish/GameData/Telemachus/ tree contains the expected Parts, WebPages, Licences, Houston, and mkon contents with the same directory structure as a Linux build. File modes are preserved (verified with stat).
  • With GITHUB_TOKEN set, the Houston download still uses the auth header (no observable change vs trunk).

Haven't re-run CI from scratch, but the existing CI is on Linux and the changes are no-ops there — the ${arr[@]+...} form expands identically to "${arr[@]}" on bash 4+, and cp -pR matches cp -ra's preservation semantics on GNU coreutils.

Two small tweaks so the post-build step runs cleanly under a
wider range of bash versions and coreutils variants:

  - `${authHeader[@]+"${authHeader[@]}"}` portably expands a
    possibly-empty array under `set -o nounset`. The previous
    form works on bash 4+ but errors on older bash versions
    still shipped as `/bin/bash` on some platforms.
  - `cp -pR` is POSIX-compliant and preserves the same metadata
    (modes + timestamps) the previous `cp -ra` did, while
    working under both GNU and BSD coreutils.

Behaviour-preserving on the existing build path.
@jonpepler jonpepler force-pushed the telemachus/afterbuild-macos branch from e64867d to 72fa7a7 Compare May 11, 2026 17:37
@jonpepler jonpepler changed the title fix: AfterBuild.sh portability for macOS chore: broaden AfterBuild.sh portability May 11, 2026
@jonpepler jonpepler marked this pull request as ready for review May 11, 2026 17:40
@SolAstrius
Copy link
Copy Markdown
Member

LGTM

@SolAstrius SolAstrius merged commit a681862 into TeaGuild:main May 11, 2026
2 checks passed
@jonpepler jonpepler deleted the telemachus/afterbuild-macos branch May 12, 2026 00:09
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.

2 participants