diff options
author | Michał Górny <mgorny@gentoo.org> | 2017-02-22 20:40:06 +0100 |
---|---|---|
committer | Michał Górny <mgorny@gentoo.org> | 2017-03-08 08:35:29 +0100 |
commit | b8fd8d3124411a8b046898a1c578fe6295e96dd0 (patch) | |
tree | 1d908f608e2c735521acc433dfbe3822a497cab9 /eclass/java-ant-2.eclass | |
parent | flag-o-matic.eclass: Replace unnecessary evals (diff) | |
download | gentoo-b8fd8d3124411a8b046898a1c578fe6295e96dd0.tar.gz gentoo-b8fd8d3124411a8b046898a1c578fe6295e96dd0.tar.bz2 gentoo-b8fd8d3124411a8b046898a1c578fe6295e96dd0.zip |
java-ant-2.eclass: Replace unnecessary evals with arrays
Replace the horrifying use of evals along with quoting to pass multiple
filenames whitespace-safe with much simpler bash arrays. While at it,
also simplify the find-read loop.
Diffstat (limited to 'eclass/java-ant-2.eclass')
-rw-r--r-- | eclass/java-ant-2.eclass | 40 |
1 files changed, 18 insertions, 22 deletions
diff --git a/eclass/java-ant-2.eclass b/eclass/java-ant-2.eclass index a72fb948eeef..b49adc3137f1 100644 --- a/eclass/java-ant-2.eclass +++ b/eclass/java-ant-2.eclass @@ -160,16 +160,12 @@ java-ant_bsfix() { find_args="${find_args} -type f ( -name ${JAVA_PKG_BSFIX_NAME// / -o -name } )" - # This voodoo is done for paths with spaces - local bsfix_these - while read line; do - [[ -z ${line} ]] && continue - bsfix_these="${bsfix_these} '${line}'" - done <<-EOF - $(find . ${find_args}) - EOF + local bsfix_these=() line + while IFS= read -r -d $'\0' line; do + bsfix_these+=( "${line}" ) + done < <(find . ${find_args} -print0) - [[ "${bsfix_these// /}" ]] && eval java-ant_bsfix_files ${bsfix_these} + [[ "${bsfix_these[@]}" ]] && java-ant_bsfix_files "${bsfix_these[@]}" popd > /dev/null || die } @@ -227,7 +223,7 @@ java-ant_bsfix_files() { eerror "Please file a bug about this on bugs.gentoo.org" die "Could not find valid -source/-target values" else - local files + local files=() for file in "${@}"; do debug-print "${FUNCNAME}: ${file}" @@ -240,7 +236,7 @@ java-ant_bsfix_files() { chmod u+w "${file}" || die "chmod u+w ${file} failed" fi - files="${files} -f '${file}'" + files+=( -f "${file}" ) done # for javadoc target and all in one pass, we need the new rewriter. @@ -254,7 +250,7 @@ java-ant_bsfix_files() { if [[ -x ${rewriter4} && ${JAVA_ANT_ENCODING} ]]; then [[ ${JAVA_ANT_REWRITE_CLASSPATH} ]] && local gcp="-g" [[ ${JAVA_ANT_ENCODING} ]] && local enc="-e ${JAVA_ANT_ENCODING}" - eval echo "cElementTree rewriter" + echo "cElementTree rewriter" debug-print "${rewriter4} extra args: ${gcp} ${enc}" ${rewriter4} ${gcp} ${enc} \ -c "${JAVA_PKG_BSFIX_SOURCE_TAGS}" source ${want_source} \ @@ -262,31 +258,31 @@ java-ant_bsfix_files() { "${@}" || die "build-xml-rewrite failed" elif [[ ! -f ${rewriter3} ]]; then debug-print "Using second generation rewriter" - eval echo "Rewriting source attributes" - eval xml-rewrite-2.py ${files} \ + echo "Rewriting source attributes" + xml-rewrite-2.py "${files[@]}" \ -c -e ${JAVA_PKG_BSFIX_SOURCE_TAGS// / -e } \ -a source -v ${want_source} || _bsfix_die "xml-rewrite2 failed: ${file}" - eval echo "Rewriting target attributes" - eval xml-rewrite-2.py ${files} \ + echo "Rewriting target attributes" + xml-rewrite-2.py "${files[@]}" \ -c -e ${JAVA_PKG_BSFIX_TARGET_TAGS// / -e } \ -a target -v ${want_target} || _bsfix_die "xml-rewrite2 failed: ${file}" - eval echo "Rewriting nowarn attributes" - eval xml-rewrite-2.py ${files} \ + echo "Rewriting nowarn attributes" + xml-rewrite-2.py "${files[@]}" \ -c -e ${JAVA_PKG_BSFIX_TARGET_TAGS// / -e } \ -a nowarn -v yes || _bsfix_die "xml-rewrite2 failed: ${file}" if [[ ${JAVA_ANT_REWRITE_CLASSPATH} ]]; then - eval echo "Adding gentoo.classpath to javac tasks" - eval xml-rewrite-2.py ${files} \ + echo "Adding gentoo.classpath to javac tasks" + xml-rewrite-2.py "${files[@]}" \ -c -e javac -e xjavac -a classpath -v \ '\${gentoo.classpath}' \ || _bsfix_die "xml-rewrite2 failed" fi else debug-print "Using third generation rewriter" - eval echo "Rewriting attributes" + echo "Rewriting attributes" local bsfix_extra_args="" # WARNING KEEP THE ORDER, ESPECIALLY FOR CHANGED ATTRIBUTES! if [[ -n ${JAVA_ANT_REWRITE_CLASSPATH} ]]; then @@ -333,7 +329,7 @@ java-ant_bsfix_files() { debug-print "bsfix_extra_args: ${bsfix_extra_args}" - eval ${rewriter3} ${files} \ + ${rewriter3} "${files[@]}" \ -c --source-element ${JAVA_PKG_BSFIX_SOURCE_TAGS// / --source-element } \ --source-attribute source --source-value ${want_source} \ --target-element ${JAVA_PKG_BSFIX_TARGET_TAGS// / --target-element } \ |