Gentoo Archives: gentoo-commits

From: "Michał Górny" <mgorny@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: eclass/
Date: Wed, 08 Mar 2017 07:36:21
Message-Id: 1488958535.57f836431666db3fd058e6f4e93f7231fcac748c.mgorny@gentoo
1 commit: 57f836431666db3fd058e6f4e93f7231fcac748c
2 Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
3 AuthorDate: Thu Feb 23 19:08:24 2017 +0000
4 Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
5 CommitDate: Wed Mar 8 07:35:35 2017 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=57f83643
7
8 ruby-ng.eclass: Replace unnecessary 'eval ls' with array fnexp
9
10 Replace the unnecessary use of 'eval ls -d ...' with much simpler
11 and safer filename expansion via bash array. The 'eval' was completely
12 unnecessary in the original code; however, the late addition of quoting
13 would have broken it if eval did not implicitly discard the quotes.
14 The 'ls -d' was unnecessary as well since bash performs filename
15 expansion before passing the parameter to 'ls'.
16
17 Furthermore, a check for accidental multiple expansion has been added.
18 A complementary check for failed expansion can not be added since
19 the function is called in src_unpack() as well and the expansion fails
20 then.
21
22 eclass/ruby-ng.eclass | 11 +++++++++--
23 1 file changed, 9 insertions(+), 2 deletions(-)
24
25 diff --git a/eclass/ruby-ng.eclass b/eclass/ruby-ng.eclass
26 index 6bdc210e4fa..13b00553c0b 100644
27 --- a/eclass/ruby-ng.eclass
28 +++ b/eclass/ruby-ng.eclass
29 @@ -1,4 +1,4 @@
30 -# Copyright 1999-2016 Gentoo Foundation
31 +# Copyright 1999-2017 Gentoo Foundation
32 # Distributed under the terms of the GNU General Public License v2
33
34 # @ECLASS: ruby-ng.eclass
35 @@ -325,7 +325,14 @@ _ruby_invoke_environment() {
36 ;;
37 esac
38 pushd "${WORKDIR}"/all &>/dev/null || die
39 - sub_S=$(eval ls -d "${sub_S}" 2>/dev/null)
40 + # use an array to trigger filename expansion
41 + # fun fact: this expansion fails in src_unpack() but the original
42 + # code did not have any checks for failed expansion, so we can't
43 + # really add one now without redesigning stuff hard.
44 + sub_S=( ${sub_S} )
45 + if [[ ${#sub_S[@]} -gt 1 ]]; then
46 + die "sub_S did expand to multiple paths: ${sub_S[*]}"
47 + fi
48 popd &>/dev/null || die
49 fi