summaryrefslogtreecommitdiff
path: root/eclass
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2014-09-04 14:52:58 +0000
committerMichał Górny <mgorny@gentoo.org>2014-09-04 14:52:58 +0000
commit35a078d03d0ba4d2701d7890457020e7fcac29a3 (patch)
tree341af160e8460b96355017282c3049592c2f942f /eclass
parentVersion bump. (diff)
downloadgentoo-2-35a078d03d0ba4d2701d7890457020e7fcac29a3.tar.gz
gentoo-2-35a078d03d0ba4d2701d7890457020e7fcac29a3.tar.bz2
gentoo-2-35a078d03d0ba4d2701d7890457020e7fcac29a3.zip
Preserve all whitespace in shebangs, and add regression test for that. Also, prevent filename expansion when word-splitting it. Bug #522080.
Diffstat (limited to 'eclass')
-rw-r--r--eclass/ChangeLog7
-rw-r--r--eclass/python-utils-r1.eclass9
-rwxr-xr-xeclass/tests/python-utils-r1.sh3
3 files changed, 15 insertions, 4 deletions
diff --git a/eclass/ChangeLog b/eclass/ChangeLog
index 1bd657069890..7056a212465e 100644
--- a/eclass/ChangeLog
+++ b/eclass/ChangeLog
@@ -1,6 +1,11 @@
# ChangeLog for eclass directory
# Copyright 1999-2014 Gentoo Foundation; Distributed under the GPL v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/ChangeLog,v 1.1365 2014/09/04 14:00:43 mgorny Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/ChangeLog,v 1.1366 2014/09/04 14:52:58 mgorny Exp $
+
+ 04 Sep 2014; Michał Górny <mgorny@gentoo.org> python-utils-r1.eclass,
+ tests/python-utils-r1.sh:
+ Preserve all whitespace in shebangs, and add regression test for that. Also,
+ prevent filename expansion when word-splitting it. Bug #522080.
04 Sep 2014; Michał Górny <mgorny@gentoo.org> tests/python-utils-r1.sh:
Fix tests for python_is_python3.
diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
index 02f7d9fae177..36fbd117b623 100644
--- a/eclass/python-utils-r1.eclass
+++ b/eclass/python-utils-r1.eclass
@@ -1,6 +1,6 @@
# Copyright 1999-2014 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/python-utils-r1.eclass,v 1.60 2014/07/06 11:45:20 mgorny Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/python-utils-r1.eclass,v 1.61 2014/09/04 14:52:58 mgorny Exp $
# @ECLASS: python-utils-r1
# @MAINTAINER:
@@ -960,13 +960,16 @@ python_fix_shebang() {
local shebang i
local error= from=
- read shebang <"${f}"
+ IFS= read -r shebang <${f}
# First, check if it's shebang at all...
if [[ ${shebang} == '#!'* ]]; then
+ local split_shebang=()
+ read -r -a split_shebang <<<${shebang}
+
# Match left-to-right in a loop, to avoid matching random
# repetitions like 'python2.7 python2'.
- for i in ${shebang}; do
+ for i in "${split_shebang[@]}"; do
case "${i}" in
*"${EPYTHON}")
debug-print "${FUNCNAME}: in file ${f#${D}}"
diff --git a/eclass/tests/python-utils-r1.sh b/eclass/tests/python-utils-r1.sh
index 5128bf9c8f8b..e417fced6e1d 100755
--- a/eclass/tests/python-utils-r1.sh
+++ b/eclass/tests/python-utils-r1.sh
@@ -134,6 +134,9 @@ test_fix_shebang '#!/mnt/python2/usr/bin/python3 python2' python2.7 \
'#!/mnt/python2/usr/bin/python2.7 python2' --force
test_fix_shebang '#!/usr/bin/foo' python2.7 FAIL
+# regression test for bug #522080
+test_fix_shebang '#!/usr/bin/python ' python2.7 '#!/usr/bin/python2.7 '
+
# make sure we don't break pattern matching
test_is "_python_impl_supported python2_5" 1
test_is "_python_impl_supported python2_6" 1