chore: broaden AfterBuild.sh portability#87
Merged
Conversation
2 tasks
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.
e64867d to
72fa7a7
Compare
Member
|
LGTM |
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.
Summary
Two small tweaks to
Telemachus/AfterBuild.shso the post-build step runs cleanly under a wider range of bash versions and coreutils variants. Behaviour-preserving on the existing build path.Changes
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 whenGITHUB_TOKENis set.cp -pRinstead ofcp -ra—-ais a GNU shorthand for-dR --preserve=allthat BSDcpdoesn't accept in the combined short form.cp -pRis POSIX-compliant, preserves modes + timestamps (the bits the previous-apreserved 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 Releasecompletes successfully;publish/api-schema.jsonis regenerated and contains the same entry shapes as before.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 withstat).GITHUB_TOKENset, 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+, andcp -pRmatchescp -ra's preservation semantics on GNU coreutils.