hooks/rewrite-python-shebang: simplify and check for unset $off correctly.

This commit is contained in:
Juan RP 2016-04-17 17:12:14 +02:00
parent 947966bd76
commit 054a73caf2
1 changed files with 4 additions and 5 deletions

View File

@ -2,7 +2,7 @@
# - rewrites python shebangs with the corresponding python version
hook() {
local pyver= shebang= warn=
local pyver= shebang= warn= off=
case $pkgname in
python-*)
@ -26,11 +26,10 @@ hook() {
shebang="#!/usr/bin/python$pyver"
find ${PKGDESTDIR} -type f -print0 | \
xargs -0 grep -H -b -m 1 "^#!.*\([[:space:]]\|/\)python\([[:space:]]\|$\)" -- | while IFS=: read -r f off _; do
[ "$off" -a "$off" -eq 0 ] || continue
[ -z "$off" ] && continue
if [ "$warn" ]; then
msg_warn "$pkgname: multiple python versions defined!"
msg_warn "$pkgname: using $pyver for shebang"
warn=
msg_warn "$pkgver: multiple python versions defined! (using $pyver for shebangs)\n"
unset warn
fi
echo " Unversioned shebang replaced by '$shebang': ${f#$PKGDESTDIR}"
sed -i "1s@.*python@${shebang}@" -- "$f"