Gentoo Archives: gentoo-dev

From: "Michał Górny" <mgorny@g.o>
To: gentoo-dev@l.g.o
Cc: "Michał Górny" <mgorny@g.o>
Subject: [gentoo-dev] [PATCH 1/2] python-utils-r1.eclass: python_fix_shebang, skip empty files
Date: Thu, 26 Nov 2015 22:30:36
Message-Id: 1448577009-32161-1-git-send-email-mgorny@gentoo.org
In Reply to: [gentoo-dev] [PATCHES] Clean-up & EAPI 6 support for python-r1 suite by "Michał Górny"
1 Skip empty files when traversing directories in python_fix_shebangs.
2 This prevents read from failing on them, and avoids opening them
3 unnecessarily.
4 ---
5 eclass/python-utils-r1.eclass | 9 ++++++---
6 1 file changed, 6 insertions(+), 3 deletions(-)
7
8 diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
9 index 0a04e12..95689f6 100644
10 --- a/eclass/python-utils-r1.eclass
11 +++ b/eclass/python-utils-r1.eclass
12 @@ -1030,9 +1030,12 @@ python_fix_shebang() {
13
14 local path f
15 for path; do
16 - local any_correct any_fixed is_recursive
17 + local any_correct any_fixed find_args is_recursive
18
19 - [[ -d ${path} ]] && is_recursive=1
20 + if [[ -d ${path} ]]; then
21 + is_recursive=1
22 + find_args=( -size +0c )
23 + fi
24
25 while IFS= read -r -d '' f; do
26 local shebang i
27 @@ -1128,7 +1131,7 @@ python_fix_shebang() {
28 eerror " requested impl: ${EPYTHON}"
29 die "${FUNCNAME}: conversion of incompatible shebang requested"
30 fi
31 - done < <(find "${path}" -type f -print0 || die)
32 + done < <(find "${path}" -type f "${find_args[@]}" -print0 || die)
33
34 if [[ ! ${any_fixed} ]]; then
35 eqawarn "QA warning: ${FUNCNAME}, ${path#${D}} did not match any fixable files."
36 --
37 2.6.3

Replies