Spiff up shebang-fixing snippet

This commit is contained in:
Benjamin A. Beasley 2021-08-20 12:25:27 -04:00
parent 7307de30c3
commit 791e0d22f9
1 changed files with 4 additions and 9 deletions

View File

@ -672,15 +672,10 @@ find . -type f -name .gitignore -print -delete
echo '===== Fixing shebangs =====' 2>&1 echo '===== Fixing shebangs =====' 2>&1
# Find executables with /usr/bin/env shebangs in the examples, and fix them. # Find executables with /usr/bin/env shebangs in the examples, and fix them.
find examples -type f -perm /0111 | find . -type f -perm /0111 -exec gawk \
while read -r fn '/^#!\/usr\/bin\/env[[:blank:]]/ { print FILENAME }; { nextfile }' \
do '{}' '+' |
if head -n 1 "${fn}" | grep -E '^#!/usr/bin/env[[:blank:]]' xargs -r sed -r -i '1{s|^(#!/usr/bin/)env[[:blank:]]+([^[:blank:]]+)|\1\2|}' \
then
sed -r -i '1{s|^(#!/usr/bin/)env[[:blank:]]+([^[:blank:]]+)|\1\2|}' \
"${fn}"
fi
done
echo '===== Fixing line endings =====' 2>&1 echo '===== Fixing line endings =====' 2>&1
# Fix some CRNL line endings: # Fix some CRNL line endings: