Gentoo Archives: gentoo-dev

From: Ulrich Mueller <ulm@g.o>
To: gentoo-dev@l.g.o
Subject: Re: [gentoo-dev] Re: [PATCH] eclass/kernel-2.eclass: Remove use of tr in global scope
Date: Thu, 31 Aug 2017 09:24:26
Message-Id: 22951.54718.362026.433723@a1i15.kph.uni-mainz.de
In Reply to: Re: [gentoo-dev] Re: [PATCH] eclass/kernel-2.eclass: Remove use of tr in global scope by "Michał Górny"
1 >>>>> On Thu, 31 Aug 2017, Michał Górny wrote:
2
3 >> > @@ -1425,9 +1426,10 @@ detect_arch() {
4 >> > COMPAT_URI="${!COMPAT_URI}"
5 >> >
6 >> > [[ -n ${COMPAT_URI} ]] && \
7 >> > - ARCH_URI="${ARCH_URI} $(echo ${LOOP_ARCH} | tr '[:upper:]' '[:lower:]')? ( ${COMPAT_URI} )"
8 >> > + ARCH_URI="${ARCH_URI} ${LOOP_ARCH,,}? ( ${COMPAT_URI} )"
9 >> >
10 >> > - if [[ ${LOOP_ARCH} == "$(echo $(tc-arch-kernel) | tr '[:lower:]' '[:upper:]')" ]]; then
11 >> > + TC_ARCH_KERNEL=$(tc-arch-kernel);
12 >> > + if [[ ${LOOP_ARCH} == ${TC_ARCH_KERNEL^^} ]]; then
13 >> >
14 >> >
15 >>
16 >> Unfortunately, the ${VAR,,} and ${VAR^^} forms were added in bash
17 >> 4.0 [1], which means they are not available in EAPIs before 6,
18 >> which only allow constructs from bash 3.2 [2].
19 >>
20 >> [1]: https://tiswww.case.edu/php/chet/bash/NEWS
21 >> [2]: https://projects.gentoo.org/pms/6/pms.html#x1-640006
22
23 > That's what I wanted to say. However, considering it's broken
24 > anyway, I guess this is kind of improvement (since it technically
25 > breaks old ebuilds only).
26
27 Many kernel ebuilds are still at EAPI 5, though.
28
29 > As a cheap alternative, you could just do a big 'case' with
30 > hardcoded mappings. Or given that ALL_ARCH is already defined, you
31 > can define ALL_ARCH_LC (lowercase) and map from one to the other.
32
33 There is also "shopt -s nocasematch" which is available since
34 bash 3.1.
35
36 Ulrich