From 31d8bb1fd6ce44013887bfe9c61d75127a787f68 Mon Sep 17 00:00:00 2001 From: emma Date: Sat, 12 Nov 2022 03:11:20 -0500 Subject: [PATCH] portability B) --- "\\" | 26 ++++++++++++++++++++++++++ check_licenses.sh | 12 +++++++++--- 2 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 "\\" diff --git "a/\\" "b/\\" new file mode 100644 index 0000000..5250114 --- /dev/null +++ "b/\\" @@ -0,0 +1,26 @@ +#!/bin/sh + +set -e + +# check usage +if ! test -n "$1"; then + printf "Usage: %s [file...]\n" "$0" 1>&2 + exit 64 # sysexits(3) EX_USAGE +fi + +# check if we have rg(1); if not, use find(1) and sed(1) instead +if ! command -v rg >/dev/null 2>&1; then + files="$(find "$PWD" -name "$1")" + for file in $files; do + if ! test -n \ + "$(sed -n \ + '\|Copyright\|p' \ + <"$file")" + then + ! test "$file" = "$1" && printf "%s\n" "$file" + fi + done +else + rg --multiline --files-without-match --glob "$1" --pcre2 \ + '(?/dev/null 2>&1; then - printf "%s: Missing dependency: rg(1)\n" "$0" 1>&2 - exit 69 # sysexits(3) EX_UNAVAILABLE + files="$(find "$PWD" -name "$1")" + for file in $files; do + if ! test -n \ + "$(sed -n '\|// SPDX-License-Identifier: .*|p' <"$file")" + then + ! test "$file" = "$1" && printf "%s\n" "$file" + fi + done else rg --multiline --files-without-match --glob "$1" --pcre2 \ '(?