Rewrite list-licenses.sh to use array+find

This commit is contained in:
Mikhail f. Shiryaev 2024-03-14 13:49:05 +01:00
parent 97b0513f99
commit a5331ea544
No known key found for this signature in database
GPG Key ID: 4B02ED204C7D93F4

View File

@ -5,15 +5,16 @@ if [[ "$OSTYPE" == "darwin"* ]]; then
GREP_CMD=ggrep
FIND_CMD=gfind
else
FIND_CMD=find
GREP_CMD=grep
FIND_CMD='find'
GREP_CMD='grep'
fi
ROOT_PATH="$(git rev-parse --show-toplevel)"
LIBS_PATH="${ROOT_PATH}/contrib"
ls -1 -d ${LIBS_PATH}/*/ "${ROOT_PATH}/base/poco" | ${GREP_CMD} -F -v -- '-cmake' | LC_ALL=C sort | while read LIB; do
LIB_NAME=$(basename $LIB)
mapfile -t libs < <(echo "${ROOT_PATH}/base/poco"; find "${LIBS_PATH}" -type d -maxdepth 1 ! -name '*-cmake' | LC_ALL=C sort)
for LIB in "${libs[@]}"; do
LIB_NAME=$(basename "$LIB")
LIB_LICENSE=$(
LC_ALL=C ${FIND_CMD} "$LIB" -type f -and '(' -iname 'LICENSE*' -or -iname 'COPYING*' -or -iname 'COPYRIGHT*' ')' -and -not '(' -iname '*.html' -or -iname '*.htm' -or -iname '*.rtf' -or -name '*.cpp' -or -name '*.h' -or -iname '*.json' ')' -printf "%d\t%p\n" |