Gentoo Archives: gentoo-dev

From: "Michał Górny" <mgorny@g.o>
To: gentoo-dev@l.g.o
Cc: "Michał Górny" <mgorny@g.o>
Subject: [gentoo-dev] [PATCH] unpacker.eclass: Replace unnecessary eval with array
Date: Thu, 23 Feb 2017 19:47:26
Message-Id: 20170223194711.29453-1-mgorny@gentoo.org
1 Replace the eval used to attempt to construct whitespace-path-safe
2 utility calls with much simpler bash arrays.
3 ---
4 eclass/unpacker.eclass | 18 +++++++++---------
5 1 file changed, 9 insertions(+), 9 deletions(-)
6
7 diff --git a/eclass/unpacker.eclass b/eclass/unpacker.eclass
8 index 610765fbca8e..27d93eb37d98 100644
9 --- a/eclass/unpacker.eclass
10 +++ b/eclass/unpacker.eclass
11 @@ -1,4 +1,4 @@
12 -# Copyright 1999-2014 Gentoo Foundation
13 +# Copyright 1999-2017 Gentoo Foundation
14 # Distributed under the terms of the GNU General Public License v2
15 # $Id$
16
17 @@ -219,30 +219,30 @@ unpack_makeself() {
18 debug-print "Detected Makeself version ${ver} ... using ${skip} as offset"
19 fi
20 case ${exe} in
21 - tail) exe="tail -n +${skip} '${src}'";;
22 - dd) exe="dd ibs=${skip} skip=1 if='${src}'";;
23 + tail) exe=( tail -n +${skip} "${src}" );;
24 + dd) exe=( dd ibs=${skip} skip=1 if="${src}" );;
25 *) die "makeself cant handle exe '${exe}'"
26 esac
27
28 # lets grab the first few bytes of the file to figure out what kind of archive it is
29 local filetype tmpfile="${T}/${FUNCNAME}"
30 - eval ${exe} 2>/dev/null | head -c 512 > "${tmpfile}"
31 + "${exe[@]}" 2>/dev/null | head -c 512 > "${tmpfile}"
32 filetype=$(file -b "${tmpfile}") || die
33 case ${filetype} in
34 *tar\ archive*)
35 - eval ${exe} | tar --no-same-owner -xf -
36 + "${exe[@]}" | tar --no-same-owner -xf -
37 ;;
38 bzip2*)
39 - eval ${exe} | bzip2 -dc | tar --no-same-owner -xf -
40 + "${exe[@]}" | bzip2 -dc | tar --no-same-owner -xf -
41 ;;
42 gzip*)
43 - eval ${exe} | tar --no-same-owner -xzf -
44 + "${exe[@]}" | tar --no-same-owner -xzf -
45 ;;
46 compress*)
47 - eval ${exe} | gunzip | tar --no-same-owner -xf -
48 + "${exe[@]}" | gunzip | tar --no-same-owner -xf -
49 ;;
50 XZ*)
51 - eval ${exe} | unxz | tar --no-same-owner -xf -
52 + "${exe[@]}" | unxz | tar --no-same-owner -xf -
53 ;;
54 *)
55 eerror "Unknown filetype \"${filetype}\" ?"
56 --
57 2.11.1