1 |
>>>>> On Sat, 3 Aug 2013, Micha³ Górny wrote: |
2 |
|
3 |
> 2. The eclass comes with a pure bash-3.2 CamelCase converter for |
4 |
> changing PNs like 'twisted-foo' into 'TwistedFoo'. The relevant code |
5 |
> can be moved to eutils as portable replacements for bash-4 ${foo^} |
6 |
> and friends. |
7 |
|
8 |
> # obtain octal ASCII code for the first letter. |
9 |
> local ord=$(printf '%o' "'${fl}") |
10 |
> |
11 |
> # check if it's [a-z]. ASCII codes are locale-safe. |
12 |
> if [[ ${ord} -ge 141 && ${ord} -le 172 ]]; then |
13 |
> # now substract 040 to make it upper-case. |
14 |
> # fun fact: in range 0141..0172, decimal '- 40' is fine. |
15 |
> local ord=$(( ${ord} - 40)) |
16 |
> # and convert it back to the character. |
17 |
> fl=$(printf '\'${ord}) |
18 |
> fi |
19 |
|
20 |
This looks just horrible. You do decimal arithmetic on octal numbers? |
21 |
|
22 |
Ulrich |