l10n: AGENTS.md: fix counter fallbacks

Reading a counter with "cmd || echo 0" breaks whenever the command
writes output but still exits non-zero. On zero matches, "grep -c"
prints 0 and exits with status 1, so the command substitution
captured two zeros and the arithmetic that follows failed with a
syntax error instead of evaluating to 0.

Fix by ignoring the exit status with "|| true" and defaulting the
empty value with "${VAR:-0}". Apply this to ENTRY_COUNT in both
l10n_one_batch() and review_one_batch(), and to the BATCH counter
read from po/review-batch.txt, which used the same fragile fallback.

Signed-off-by: Jiang Xin <worldhello.net@gmail.com>
This commit is contained in:
Jiang Xin committed 2026-09-27 15:57:51 +08:00
1 parent 0f8e75abeb
commit b758bc5bc4
1 file changed
+6 -4
+6 -4
View File
@@ -543,9 +543,9 @@ step 8 after step 6.
DONE_PO="po/l10n-done.po"
rm -f "$TODO_JSON" "$TODO_PO" "$DONE_JSON" "$DONE_PO"
ENTRY_COUNT=$(grep -c '^msgid ' "$PENDING" 2>/dev/null || echo 0)
ENTRY_COUNT=$(grep -c '^msgid ' "$PENDING" 2>/dev/null || true)
ENTRY_COUNT=${ENTRY_COUNT:-0}
ENTRY_COUNT=$((ENTRY_COUNT > 0 ? ENTRY_COUNT - 1 : 0))
if test "$ENTRY_COUNT" -gt $min_batch_size
then
if test "$ENTRY_COUNT" -gt $((min_batch_size * 8))
@@ -772,7 +772,8 @@ already present.
cp "$INPUT_PO" "$PENDING"
fi
ENTRY_COUNT=$(grep -c '^msgid ' "$PENDING" 2>/dev/null || echo 0)
ENTRY_COUNT=$(grep -c '^msgid ' "$PENDING" 2>/dev/null || true)
ENTRY_COUNT=${ENTRY_COUNT:-0}
ENTRY_COUNT=$((ENTRY_COUNT > 0 ? ENTRY_COUNT - 1 : 0))
if test "$ENTRY_COUNT" -eq 0
then
@@ -796,7 +797,8 @@ already present.
NUM=$ENTRY_COUNT
fi
BATCH=$(cat "$BATCH_FILE" 2>/dev/null || echo 0)
BATCH=$(cat "$BATCH_FILE" 2>/dev/null || true)
BATCH=${BATCH:-0}
BATCH=$((BATCH + 1))
echo "$BATCH" >"$BATCH_FILE"