> Philip Hands <p...@hands.com> writes: > ... > > BTW I would suggest using: > > ${LOCALE%%_*} in place of the $(echo ... | cut ...)
Yes, I ended using that too in my version of the script, but I sent the bug report earlier:).
Philip Hands <p...@hands.com> writes: ... This is what it should have been: https://salsa.debian.org/philh/localechooser/-/commit/1e511957c05724bb417c07a84894bcb999a95b28 The subsequent commits in both versions of that branch did arrive at the same destination, even if the middle bit was a bit tangled. ... Cheers, Phil.
I tested Phil's "sed" command in terminal like this (all one line - email splits it):
L=cs_CZ.UTF-8; sed -n "/^${L%%_*}/"'{s/^[[:alpha:]]*;\([[:digit:]]\);.*/\1/p;q}' languagelist
and it seemed to work - with "cs_CZ.UTF-8" locale it returned 2. But some locales still returned wrong level. After using a modified "sed" command I think I got it working even for locales like "zh_TW.UTF-8" or "nn_NO.UTF-8" etc.:
L=zh_TW.UTF-8; sed -n "/^${L%%_*}/"'{s/^[A-Za-z_]*;\([0-9]\);.*/\1/p;q}' languagelist
returns 3 and with "nn_NO.UTF-8" it returns 1. I guess "[[:alpha:]]" does not include "_".
Anyway it is a nice improvement doing all the work with one "sed" process compared to that "wild pipelined bunch of cutting greps and heads". So, thanks to what Phil "sed", I am now upgrading my version of the script to the "sed" approach:).
Cheers, Jmkr