diff options
author | Michał Górny <mgorny@gentoo.org> | 2017-02-23 20:08:24 +0100 |
---|---|---|
committer | Michał Górny <mgorny@gentoo.org> | 2017-03-08 08:35:35 +0100 |
commit | 57f836431666db3fd058e6f4e93f7231fcac748c (patch) | |
tree | fac73b3042a7eed56ebda8e179757f2327a1f78a /eclass | |
parent | ruby-fakegem.eclass: Remove completely unnecessary 'eval ls' (diff) | |
download | gentoo-57f836431666db3fd058e6f4e93f7231fcac748c.tar.gz gentoo-57f836431666db3fd058e6f4e93f7231fcac748c.tar.bz2 gentoo-57f836431666db3fd058e6f4e93f7231fcac748c.zip |
ruby-ng.eclass: Replace unnecessary 'eval ls' with array fnexp
Replace the unnecessary use of 'eval ls -d ...' with much simpler
and safer filename expansion via bash array. The 'eval' was completely
unnecessary in the original code; however, the late addition of quoting
would have broken it if eval did not implicitly discard the quotes.
The 'ls -d' was unnecessary as well since bash performs filename
expansion before passing the parameter to 'ls'.
Furthermore, a check for accidental multiple expansion has been added.
A complementary check for failed expansion can not be added since
the function is called in src_unpack() as well and the expansion fails
then.
Diffstat (limited to 'eclass')
-rw-r--r-- | eclass/ruby-ng.eclass | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/eclass/ruby-ng.eclass b/eclass/ruby-ng.eclass index 6bdc210e4faa..13b00553c0b0 100644 --- a/eclass/ruby-ng.eclass +++ b/eclass/ruby-ng.eclass @@ -1,4 +1,4 @@ -# Copyright 1999-2016 Gentoo Foundation +# Copyright 1999-2017 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # @ECLASS: ruby-ng.eclass @@ -325,7 +325,14 @@ _ruby_invoke_environment() { ;; esac pushd "${WORKDIR}"/all &>/dev/null || die - sub_S=$(eval ls -d "${sub_S}" 2>/dev/null) + # use an array to trigger filename expansion + # fun fact: this expansion fails in src_unpack() but the original + # code did not have any checks for failed expansion, so we can't + # really add one now without redesigning stuff hard. + sub_S=( ${sub_S} ) + if [[ ${#sub_S[@]} -gt 1 ]]; then + die "sub_S did expand to multiple paths: ${sub_S[*]}" + fi popd &>/dev/null || die fi |