docs: replace GNU-only head -n -1 in fan-out plan with bash expansion

head -n -1 fails on BSD/macOS, making the plan's local verification steps
unrunnable. Bash parameter expansion is portable and drops two subprocesses
per endpoint.

Claude-Session: https://claude.ai/code/session_01S3aqJ4tvaPezQhsGNCybut
This commit is contained in:
2026-08-04 19:31:55 +02:00
parent 81bd01c5d6
commit bca2e252fb
@@ -285,8 +285,11 @@ runs:
continue
fi
body=$(printf '%s' "$response" | head -n -1)
code=$(printf '%s' "$response" | tail -n 1)
# Split on the last newline: curl's -w appended the status code
# there. Pure bash — `head -n -1` is GNU-only and fails on
# BSD/macOS, so the fan-out could not be tested locally.
code="${response##*$'\n'}"
body="${response%$'\n'*}"
echo "HTTP $code"
printf '%s' "$body" | jq . || printf '%s\n' "$body"
@@ -306,11 +309,12 @@ runs:
echo "all $attempted endpoint(s) updated"
```
Three changes beyond the loop itself, each load-bearing:
Four changes beyond the loop itself, each load-bearing:
1. **All inputs moved into `env:`.** A multi-line `${{ inputs.endpoint }}` interpolated directly into the script body would break it syntactically. Moving the others too keeps one consistent style in a short script, and stops a value containing shell metacharacters from being executed.
2. **`jq -nc` builds the payload** instead of hand-interpolating into a JSON string. A tag containing a quote previously produced malformed JSON and a confusing 400.
3. **`set -e` dropped**, `-uo pipefail` kept. This is the whole point of the task — see the comment in the script.
4. **`head -n -1` replaced by bash parameter expansion.** The existing action used `head -n -1`, which is GNU-only — it fails on BSD/macOS with `illegal line count`. That made the fan-out logic impossible to test on a developer machine, so the portability fix is what makes Steps 2-4 runnable at all. It also drops two subprocesses per endpoint.
- [ ] **Step 2: Verify the loop continues past a failure**
@@ -364,8 +368,8 @@ while IFS= read -r endpoint; do
continue
fi
body=$(printf '%s' "$response" | head -n -1)
code=$(printf '%s' "$response" | tail -n 1)
code="${response##*$'\n'}"
body="${response%$'\n'*}"
echo "HTTP $code"
printf '%s' "$body" | jq . || printf '%s\n' "$body"