Gentoo Archives: gentoo-dev

From: Michael Orlitzky <mjo@g.o>
To: gentoo-dev@l.g.o
Subject: Re: [gentoo-dev] [PATCH] l10n.eclass: Sort and normalize PLOCALES in l10n_find_plocales_change
Date: Sun, 08 May 2016 15:21:01
Message-Id: 572F5942.4020702@gentoo.org
In Reply to: [gentoo-dev] [PATCH] l10n.eclass: Sort and normalize PLOCALES in l10n_find_plocales_change by James Le Cuirot
1 On 05/07/2016 04:13 PM, James Le Cuirot wrote:
2 >
3 > + if [[ $(tr -s "[:space:]" "\n" <<< "${PLOCALES}" | sort | xargs echo) != ${current%[[:space:]]} ]] ; then
4
5 The stuff on the left-hand side just sorts a space-separated list,
6 right? It might be time to split that into another function. It looks a
7 lot less insane when it's,
8
9 if [[ $(l10n_sort_spaces "${PLOCALES}") != ${current%[[:space:]]} ]]
10
11 Then the function would just be
12
13 # @FUNCTION: l10n_sort_spaces
14 # @DESCRIPTION:
15 # Takes a space-separated list of strings as an argument and sorts
16 # them. The output is again space-separated. This is accomplished
17 # by first replacing the spaces with newlines so that "sort" can
18 # be used, and then collecting the output back onto one line.
19 function l10n_sort_spaces() {
20 tr -s "[:space:]" "\n" <<< "${1}" | sort | xargs echo
21 }
22
23 You should also document why you're doing that nearby, since like you
24 said, the eclass assumes that PLOCALES is sorted. Someone will wonder
25 why you're doing it again.

Replies