#!/usr/bin/env bash # SPDX-License-Identifier: LicenseRef-Starship-1.0 # Copyright (c) 2023-2026 Robert A. James # check_no_patent.sh DIR -- refuse a directory of documents that holds the patent (#191, Captain Bob # 2026-11-13: "the SSRN paper but not the patent"): a file whose name says patent, or a PDF whose title does # (docs/formal/patent: "Steady-State Machine -- Patent Application"). Run by scripts/nightly.sh on what the # documents stage builds and on what a release attaches. Exit 0 and "no patent", or 1 naming each file. # Tests: scripts/test_check_no_patent.sh. set -uo pipefail dir=${1:?usage: check_no_patent.sh DIR} [ -d "$dir" ] || { echo "check_no_patent: $dir is not a directory -- refused" >&2; exit 1; } bad=0 while IFS= read -r -d '' f; do if [[ "$(basename "$f")" =~ [Pp][Aa][Tt][Ee][Nn][Tt] ]]; then echo "check_no_patent: $f is named for the patent -- refused" >&2; bad=1; continue fi case "$f" in *.pdf|*.PDF) title=$(pdfinfo "$f" 2>/dev/null | sed -n 's/^Title: *//p') if [[ "$title" =~ [Pp][Aa][Tt][Ee][Nn][Tt] ]]; then echo "check_no_patent: $f is titled \"$title\" -- the patent, refused" >&2; bad=1 fi ;; esac done < <(find "$dir" -type f -print0) [ $bad = 0 ] && echo "check_no_patent: $dir: no patent" exit $bad