Dnia 2013-08-03, o godz. 17:54:42 Ulrich Mueller <u...@gentoo.org> napisał(a):
> >>>>> On Sat, 3 Aug 2013, Michał Górny wrote: > > > 2. The eclass comes with a pure bash-3.2 CamelCase converter for > > changing PNs like 'twisted-foo' into 'TwistedFoo'. The relevant code > > can be moved to eutils as portable replacements for bash-4 ${foo^} > > and friends. > > > # obtain octal ASCII code for the first letter. > > local ord=$(printf '%o' "'${fl}") > > > > # check if it's [a-z]. ASCII codes are locale-safe. > > if [[ ${ord} -ge 141 && ${ord} -le 172 ]]; then > > # now substract 040 to make it upper-case. > > # fun fact: in range 0141..0172, decimal '- 40' is fine. > > local ord=$(( ${ord} - 40)) > > # and convert it back to the character. > > fl=$(printf '\'${ord}) > > fi > > This looks just horrible. You do decimal arithmetic on octal numbers? Yes. Bash wasn't really happy to do octal arithmetic for me. Yet in this particular case, with proper assumptions, decimal arithmetic is practically equivalent. -- Best regards, Michał Górny
signature.asc
Description: PGP signature