pattern, not file

This commit is contained in:
Emma Tebibyte 2022-11-12 03:17:40 -05:00
parent 31d8bb1fd6
commit 42abb1791d
2 changed files with 1 additions and 27 deletions

26
\
View File

@ -1,26 +0,0 @@
#!/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 \
'(?<!\n)((//)|(#)) Copyright \(c\) \d+ [A-z, ]+\n((//)|(#)) SPDX-License-Identifier: .*\n'
fi

View File

@ -4,7 +4,7 @@ set -e
# check usage
if ! test -n "$1"; then
printf "Usage: %s [file...]\n" "$0" 1>&2
printf "Usage: %s [pattern...]\n" "$0" 1>&2
exit 64 # sysexits(3) EX_USAGE
fi