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>
maint
parent
0f8e75abeb
commit
b758bc5bc4
10
po/AGENTS.md
10
po/AGENTS.md
|
|
@ -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"
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue