Skip to content

Commit 9db9981

Browse files
committed
bootstrap.sh: guard version-tracking against set -e + empty pipelines
bootstrap.sh runs with 'set -euo pipefail'. The new remote_latest_tag/remote_tip_sha helpers pipe through grep, which exits non-zero when no tags match (e.g. CI test fixtures with empty git repos). pipefail surfaces that to the command substitution, and bash 4.4+ propagates it to set -e — silently aborting bootstrap right after the version probe. Wrap each version lookup with '|| true' so a missing tag yields an empty string instead of killing the script. Behavior unchanged in the normal happy path; tests pass again.
1 parent 0d79881 commit 9db9981

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

bootstrap.sh

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,12 @@ remote_tip_sha() {
7171
}
7272

7373
CURRENT_DESC=""
74-
[ -d "$STATUSLINE_DIR/.git" ] && CURRENT_DESC=$(git_describe_head "$STATUSLINE_DIR")
75-
LATEST_TAG=$(remote_latest_tag)
76-
LATEST_TIP=$(remote_tip_sha)
74+
[ -d "$STATUSLINE_DIR/.git" ] && CURRENT_DESC=$(git_describe_head "$STATUSLINE_DIR" || true)
75+
# These are best-effort: an empty repo (e.g. test fixtures) has no tags and
76+
# `grep`/`tail` on an empty pipeline returns non-zero, which `pipefail`
77+
# propagates and `set -e` would otherwise turn into a fatal exit.
78+
LATEST_TAG=$(remote_latest_tag || true)
79+
LATEST_TIP=$(remote_tip_sha || true)
7780

7881
echo "kinncj statusline bootstrap"
7982
echo " repo: $REPO_URL"
@@ -100,7 +103,7 @@ else
100103
git -C "$STATUSLINE_DIR" fetch --depth 1 --tags origin >/dev/null 2>&1 || true
101104
fi
102105

103-
NEW_DESC=$(git_describe_head "$STATUSLINE_DIR")
106+
NEW_DESC=$(git_describe_head "$STATUSLINE_DIR" || true)
104107
if [ -z "$CURRENT_DESC" ]; then
105108
echo "✓ installed at $NEW_DESC"
106109
elif [ "$CURRENT_DESC" = "$NEW_DESC" ]; then

0 commit comments

Comments
 (0)