hooks/rewrite-python-shebang: simplify and check for unset $off correctly.
This commit is contained in:
parent
947966bd76
commit
054a73caf2
1 changed files with 4 additions and 5 deletions
|
@ -2,7 +2,7 @@
|
||||||
# - rewrites python shebangs with the corresponding python version
|
# - rewrites python shebangs with the corresponding python version
|
||||||
|
|
||||||
hook() {
|
hook() {
|
||||||
local pyver= shebang= warn=
|
local pyver= shebang= warn= off=
|
||||||
|
|
||||||
case $pkgname in
|
case $pkgname in
|
||||||
python-*)
|
python-*)
|
||||||
|
@ -26,11 +26,10 @@ hook() {
|
||||||
shebang="#!/usr/bin/python$pyver"
|
shebang="#!/usr/bin/python$pyver"
|
||||||
find ${PKGDESTDIR} -type f -print0 | \
|
find ${PKGDESTDIR} -type f -print0 | \
|
||||||
xargs -0 grep -H -b -m 1 "^#!.*\([[:space:]]\|/\)python\([[:space:]]\|$\)" -- | while IFS=: read -r f off _; do
|
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
|
if [ "$warn" ]; then
|
||||||
msg_warn "$pkgname: multiple python versions defined!"
|
msg_warn "$pkgver: multiple python versions defined! (using $pyver for shebangs)\n"
|
||||||
msg_warn "$pkgname: using $pyver for shebang"
|
unset warn
|
||||||
warn=
|
|
||||||
fi
|
fi
|
||||||
echo " Unversioned shebang replaced by '$shebang': ${f#$PKGDESTDIR}"
|
echo " Unversioned shebang replaced by '$shebang': ${f#$PKGDESTDIR}"
|
||||||
sed -i "1s@.*python@${shebang}@" -- "$f"
|
sed -i "1s@.*python@${shebang}@" -- "$f"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue