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. |