fix(deploy): grep with no matches no longer aborts script under set -e

The UNTRACKED count used 'git status --short | grep '^??' | wc -l | xargs'.
When the working tree is clean, grep exits 1 (no matches found). Combined
with 'set -euo pipefail' at the top of the script, that exit 1 killed the
script mid-preflight.

Fix: use 'grep -c' with '|| true' fallback. grep -c counts matches and
prints 0 if none; the fallback handles the exit code so set -e is happy.
This commit is contained in:
Manohar Gupta 2026-04-19 13:21:01 +05:30
parent 01ab630085
commit 03ae4072d9

View file

@ -95,7 +95,7 @@ if ! git diff-index --quiet HEAD --; then
fi fi
# [3] Untracked files of note (warn only) # [3] Untracked files of note (warn only)
UNTRACKED=$(git status --short | grep '^??' | wc -l | xargs) UNTRACKED=$(git status --short | grep -c '^??' || true)
if [ "$UNTRACKED" -gt 0 ]; then if [ "$UNTRACKED" -gt 0 ]; then
warn "$UNTRACKED untracked file(s) exist — they won't be deployed." warn "$UNTRACKED untracked file(s) exist — they won't be deployed."
fi fi