1 |
commit: b8fd8d3124411a8b046898a1c578fe6295e96dd0 |
2 |
Author: Michał Górny <mgorny <AT> gentoo <DOT> org> |
3 |
AuthorDate: Wed Feb 22 19:40:06 2017 +0000 |
4 |
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org> |
5 |
CommitDate: Wed Mar 8 07:35:29 2017 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=b8fd8d31 |
7 |
|
8 |
java-ant-2.eclass: Replace unnecessary evals with arrays |
9 |
|
10 |
Replace the horrifying use of evals along with quoting to pass multiple |
11 |
filenames whitespace-safe with much simpler bash arrays. While at it, |
12 |
also simplify the find-read loop. |
13 |
|
14 |
eclass/java-ant-2.eclass | 40 ++++++++++++++++++---------------------- |
15 |
1 file changed, 18 insertions(+), 22 deletions(-) |
16 |
|
17 |
diff --git a/eclass/java-ant-2.eclass b/eclass/java-ant-2.eclass |
18 |
index a72fb948eee..b49adc3137f 100644 |
19 |
--- a/eclass/java-ant-2.eclass |
20 |
+++ b/eclass/java-ant-2.eclass |
21 |
@@ -160,16 +160,12 @@ java-ant_bsfix() { |
22 |
|
23 |
find_args="${find_args} -type f ( -name ${JAVA_PKG_BSFIX_NAME// / -o -name } )" |
24 |
|
25 |
- # This voodoo is done for paths with spaces |
26 |
- local bsfix_these |
27 |
- while read line; do |
28 |
- [[ -z ${line} ]] && continue |
29 |
- bsfix_these="${bsfix_these} '${line}'" |
30 |
- done <<-EOF |
31 |
- $(find . ${find_args}) |
32 |
- EOF |
33 |
+ local bsfix_these=() line |
34 |
+ while IFS= read -r -d $'\0' line; do |
35 |
+ bsfix_these+=( "${line}" ) |
36 |
+ done < <(find . ${find_args} -print0) |
37 |
|
38 |
- [[ "${bsfix_these// /}" ]] && eval java-ant_bsfix_files ${bsfix_these} |
39 |
+ [[ "${bsfix_these[@]}" ]] && java-ant_bsfix_files "${bsfix_these[@]}" |
40 |
|
41 |
popd > /dev/null || die |
42 |
} |
43 |
@@ -227,7 +223,7 @@ java-ant_bsfix_files() { |
44 |
eerror "Please file a bug about this on bugs.gentoo.org" |
45 |
die "Could not find valid -source/-target values" |
46 |
else |
47 |
- local files |
48 |
+ local files=() |
49 |
|
50 |
for file in "${@}"; do |
51 |
debug-print "${FUNCNAME}: ${file}" |
52 |
@@ -240,7 +236,7 @@ java-ant_bsfix_files() { |
53 |
chmod u+w "${file}" || die "chmod u+w ${file} failed" |
54 |
fi |
55 |
|
56 |
- files="${files} -f '${file}'" |
57 |
+ files+=( -f "${file}" ) |
58 |
done |
59 |
|
60 |
# for javadoc target and all in one pass, we need the new rewriter. |
61 |
@@ -254,7 +250,7 @@ java-ant_bsfix_files() { |
62 |
if [[ -x ${rewriter4} && ${JAVA_ANT_ENCODING} ]]; then |
63 |
[[ ${JAVA_ANT_REWRITE_CLASSPATH} ]] && local gcp="-g" |
64 |
[[ ${JAVA_ANT_ENCODING} ]] && local enc="-e ${JAVA_ANT_ENCODING}" |
65 |
- eval echo "cElementTree rewriter" |
66 |
+ echo "cElementTree rewriter" |
67 |
debug-print "${rewriter4} extra args: ${gcp} ${enc}" |
68 |
${rewriter4} ${gcp} ${enc} \ |
69 |
-c "${JAVA_PKG_BSFIX_SOURCE_TAGS}" source ${want_source} \ |
70 |
@@ -262,31 +258,31 @@ java-ant_bsfix_files() { |
71 |
"${@}" || die "build-xml-rewrite failed" |
72 |
elif [[ ! -f ${rewriter3} ]]; then |
73 |
debug-print "Using second generation rewriter" |
74 |
- eval echo "Rewriting source attributes" |
75 |
- eval xml-rewrite-2.py ${files} \ |
76 |
+ echo "Rewriting source attributes" |
77 |
+ xml-rewrite-2.py "${files[@]}" \ |
78 |
-c -e ${JAVA_PKG_BSFIX_SOURCE_TAGS// / -e } \ |
79 |
-a source -v ${want_source} || _bsfix_die "xml-rewrite2 failed: ${file}" |
80 |
|
81 |
- eval echo "Rewriting target attributes" |
82 |
- eval xml-rewrite-2.py ${files} \ |
83 |
+ echo "Rewriting target attributes" |
84 |
+ xml-rewrite-2.py "${files[@]}" \ |
85 |
-c -e ${JAVA_PKG_BSFIX_TARGET_TAGS// / -e } \ |
86 |
-a target -v ${want_target} || _bsfix_die "xml-rewrite2 failed: ${file}" |
87 |
|
88 |
- eval echo "Rewriting nowarn attributes" |
89 |
- eval xml-rewrite-2.py ${files} \ |
90 |
+ echo "Rewriting nowarn attributes" |
91 |
+ xml-rewrite-2.py "${files[@]}" \ |
92 |
-c -e ${JAVA_PKG_BSFIX_TARGET_TAGS// / -e } \ |
93 |
-a nowarn -v yes || _bsfix_die "xml-rewrite2 failed: ${file}" |
94 |
|
95 |
if [[ ${JAVA_ANT_REWRITE_CLASSPATH} ]]; then |
96 |
- eval echo "Adding gentoo.classpath to javac tasks" |
97 |
- eval xml-rewrite-2.py ${files} \ |
98 |
+ echo "Adding gentoo.classpath to javac tasks" |
99 |
+ xml-rewrite-2.py "${files[@]}" \ |
100 |
-c -e javac -e xjavac -a classpath -v \ |
101 |
'\${gentoo.classpath}' \ |
102 |
|| _bsfix_die "xml-rewrite2 failed" |
103 |
fi |
104 |
else |
105 |
debug-print "Using third generation rewriter" |
106 |
- eval echo "Rewriting attributes" |
107 |
+ echo "Rewriting attributes" |
108 |
local bsfix_extra_args="" |
109 |
# WARNING KEEP THE ORDER, ESPECIALLY FOR CHANGED ATTRIBUTES! |
110 |
if [[ -n ${JAVA_ANT_REWRITE_CLASSPATH} ]]; then |
111 |
@@ -333,7 +329,7 @@ java-ant_bsfix_files() { |
112 |
|
113 |
debug-print "bsfix_extra_args: ${bsfix_extra_args}" |
114 |
|
115 |
- eval ${rewriter3} ${files} \ |
116 |
+ ${rewriter3} "${files[@]}" \ |
117 |
-c --source-element ${JAVA_PKG_BSFIX_SOURCE_TAGS// / --source-element } \ |
118 |
--source-attribute source --source-value ${want_source} \ |
119 |
--target-element ${JAVA_PKG_BSFIX_TARGET_TAGS// / --target-element } \ |