Skip to content

Commit f3a0f2d

Browse files
committed
test(e2e): avoid head -n 0 in prevlog_cap for BSD portability
A zero container cap reached head -n 0, which GNU head treats as an empty result but BSD/macOS head rejects ("illegal line count -- 0"), aborting a local run. Special-case the zero cap to consume stdin instead, so the helper behaves the same on both coreutils flavours. Assisted-By: Claude <[email protected]> Signed-off-by: Aleksei Sviridkin <[email protected]>
1 parent 76f7267 commit f3a0f2d

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

‎hack/e2e-capture-previous-logs.sh‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,14 @@ prevlog_cap() {
100100
'' | *[!0-9]*) _pc_max=12 ;;
101101
esac
102102
# A zero cap emits nothing; the caller still reports the full overflow count,
103-
# so the drop stays visible. (GNU head treats -n 0 as an empty result; BSD
104-
# head rejects it outright, which lands in the same place here -- no rows
105-
# through -- but is why this is not described as a portable no-op.)
106-
head -n "$_pc_max"
103+
# so the drop stays visible. Handle it explicitly rather than via `head -n 0`:
104+
# GNU head treats that as an empty result, but BSD/macOS head rejects it
105+
# ("illegal line count -- 0"), which would abort a local run.
106+
if [ "$_pc_max" -eq 0 ]; then
107+
cat >/dev/null
108+
else
109+
head -n "$_pc_max"
110+
fi
107111
}
108112

109113
# prevlog_logfile_name: build the per-container artifact filename for a row's

0 commit comments

Comments
 (0)