File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -401,7 +401,16 @@ test-infrastructure/vm/win.sh
401401 case " $entry " in
402402 * .py) out=$( cd " $ROOT " && python3 " $entry " --help 2>&1 ) && rc=0 || rc=$? ;;
403403 esac
404- if [ " $rc " -ne 0 ] || ! printf ' %s' " $out " | grep -q " Usage:" ; then
404+ # Substring test in-shell: piping into `grep -q` is unsafe under
405+ # `set -o pipefail` because grep exits at the first match and the
406+ # writer takes EPIPE on any payload larger than the pipe buffer,
407+ # turning a SATISFIED contract into a probe failure (macOS, 698-byte
408+ # --help vs a 512-byte PIPE_BUF).
409+ case " $out " in
410+ * " Usage:" * ) has_usage=1 ;;
411+ * ) has_usage=0 ;;
412+ esac
413+ if [ " $rc " -ne 0 ] || [ " $has_usage " -eq 0 ]; then
405414 echo " INTERFACE CONTRACT: $entry --help must exit 0 and print a Usage: block (rc=$rc )" >&2
406415 probe_failures=1
407416 fi
@@ -422,7 +431,11 @@ scripts/smoke-invariants.sh
422431"
423432 for entry in $STRICT_ENTRIES ; do
424433 out=$( cd " $ROOT " && bash " $entry " --definitely-not-a-flag 2>&1 ) && rc=0 || rc=$?
425- if [ " $rc " -ne 2 ] || ! printf ' %s' " $out " | grep -q " Please consult --help." ; then
434+ case " $out " in
435+ * " Please consult --help." * ) has_hint=1 ;;
436+ * ) has_hint=0 ;;
437+ esac
438+ if [ " $rc " -ne 2 ] || [ " $has_hint " -eq 0 ]; then
426439 echo " INTERFACE CONTRACT: $entry must reject unknown flags with exit 2 + 'Please consult --help.' (rc=$rc )" >&2
427440 probe_failures=1
428441 fi
You can’t perform that action at this time.
0 commit comments