#!/bin/bash # Regression test: --help must not spill into build/mk-bootimg.sh's own code. # # build/fetch-vendor.sh's --help sliced its own source with a hardcoded line # range that stopped one line too late, printing "set -uo pipefail" -- the # first line of code -- as the last line of help text. mk-bootimg.sh's # --help used the same hardcoded-range shape (currently pointed at the right # span), so the same slip was one header-comment edit away here too. It now # uses the same self-terminating awk pattern fetch-vendor.sh was fixed to # use, so this pins both that it stays in sync as the header grows or # shrinks and that it matches the header verbatim today. set -uo pipefail HERE="$(cd "$(dirname "$0")" && pwd)" SCRIPT="$HERE/../../build/mk-bootimg.sh" [ -f "$SCRIPT" ] || { echo "FAIL: script not found at $SCRIPT"; exit 1; } fail=0 HELP_OUT="$(bash "$SCRIPT" --help)" if printf '%s\n' "$HELP_OUT" | grep -q 'set -euo pipefail'; then echo "FAIL: --help prints the script's own code" fail=1 else echo "PASS: --help does not print the script's own code" fi LAST_LINE="$(printf '%s\n' "$HELP_OUT" | tail -1)" if [ "$LAST_LINE" = "# [--resource-tool PATH]" ]; then echo "PASS: --help ends on the last header comment line, not past it" else echo "FAIL: --help ends on the last header comment line, not past it (got: $LAST_LINE)" fail=1 fi FIRST_LINE="$(printf '%s\n' "$HELP_OUT" | head -1)" if [ "$FIRST_LINE" = "# Package a bootable boot.img from a kernel this SDK built." ]; then echo "PASS: --help starts after the shebang, not on it" else echo "FAIL: --help starts after the shebang, not on it (got: $FIRST_LINE)" fail=1 fi exit "$fail"