license-check.sh: Use xargs -0 instead of -d

Neither are in POSIX but -0 is much more portable in practice.

Despite the old comment, the grep usage should be portable already.
This commit is contained in:
Lasse Collin 2024-05-27 17:41:37 +03:00
parent 9114267038
commit fda0ec862a
1 changed files with 6 additions and 5 deletions

View File

@ -11,7 +11,7 @@
# when .git isn't available, from files extracted from a release tarball # when .git isn't available, from files extracted from a release tarball
# (in case of a release tarball, the tree must be clean of any extra files). # (in case of a release tarball, the tree must be clean of any extra files).
# #
# NOTE: This uses grep and xargs with options that aren't in POSIX. # NOTE: This relies on non-POSIX xargs -0. It's supported on GNU and *BSDs.
# #
############################################################################### ###############################################################################
# #
@ -99,11 +99,12 @@ FILES=$(printf '%s\n' "$FILES" | sort)
# Find the tagged files. # Find the tagged files.
TAGGED=$(printf '%s\n' "$FILES" | xargs -r -d '\n' grep -l "$SPDX_LI") TAGGED=$(printf '%s\n' "$FILES" \
| tr '\n' '\000' | xargs -0r grep -l "$SPDX_LI")
# Find the tagged 0BSD files. # Find the tagged 0BSD files.
TAGGED_0BSD=$(printf '%s\n' "$TAGGED" \ TAGGED_0BSD=$(printf '%s\n' "$TAGGED" \
| xargs -r -d '\n' grep -l "$SPDX_LI 0BSD") | tr '\n' '\000' | xargs -0r grep -l "$SPDX_LI 0BSD")
# Find the tagged non-0BSD files, that is, remove the 0BSD-tagged files # Find the tagged non-0BSD files, that is, remove the 0BSD-tagged files
# from the list of tagged files. # from the list of tagged files.
@ -125,8 +126,8 @@ FILES=$(printf '%s\n' "$FILES" | grep -Ev \
# FIXME: Allow untagged translations if they have a public domain notice. # FIXME: Allow untagged translations if they have a public domain notice.
# These are old translations that haven't been updated after 2024-02-14. # These are old translations that haven't been updated after 2024-02-14.
# Eventually these should go away. # Eventually these should go away.
PD_PO=$(printf '%s\n' "$FILES" | grep '\.po$' | \ PD_PO=$(printf '%s\n' "$FILES" | grep '\.po$' | tr '\n' '\000' \
xargs -r -d '\n' grep -Fl '# This file is put in the public domain.') | xargs -0r grep -Fl '# This file is put in the public domain.')
if test -n "$PD_PO"; then if test -n "$PD_PO"; then
# Remove the public domain .po files from the list. # Remove the public domain .po files from the list.