Gentoo Archives: gentoo-dev

From: "Michał Górny" <mgorny@g.o>
To: gentoo-dev@l.g.o
Cc: ulm@g.o, python@g.o
Subject: Re: [gentoo-dev] [New eclass] twisted-r1.eclass
Date: Sat, 03 Aug 2013 18:29:29
Message-Id: 20130803202935.64951485@gentoo.org
In Reply to: Re: [gentoo-dev] [New eclass] twisted-r1.eclass by Ulrich Mueller
1 Dnia 2013-08-03, o godz. 17:54:42
2 Ulrich Mueller <ulm@g.o> napisał(a):
3
4 > >>>>> On Sat, 3 Aug 2013, Michał Górny wrote:
5 >
6 > > 2. The eclass comes with a pure bash-3.2 CamelCase converter for
7 > > changing PNs like 'twisted-foo' into 'TwistedFoo'. The relevant code
8 > > can be moved to eutils as portable replacements for bash-4 ${foo^}
9 > > and friends.
10 >
11 > > # obtain octal ASCII code for the first letter.
12 > > local ord=$(printf '%o' "'${fl}")
13 > >
14 > > # check if it's [a-z]. ASCII codes are locale-safe.
15 > > if [[ ${ord} -ge 141 && ${ord} -le 172 ]]; then
16 > > # now substract 040 to make it upper-case.
17 > > # fun fact: in range 0141..0172, decimal '- 40' is fine.
18 > > local ord=$(( ${ord} - 40))
19 > > # and convert it back to the character.
20 > > fl=$(printf '\'${ord})
21 > > fi
22 >
23 > This looks just horrible. You do decimal arithmetic on octal numbers?
24
25 Yes. Bash wasn't really happy to do octal arithmetic for me. Yet
26 in this particular case, with proper assumptions, decimal arithmetic is
27 practically equivalent.
28
29 --
30 Best regards,
31 Michał Górny

Attachments

File name MIME type
signature.asc application/pgp-signature

Replies

Subject Author
Re: [gentoo-dev] [New eclass] twisted-r1.eclass Ulrich Mueller <ulm@g.o>
Re: [gentoo-dev] [New eclass] twisted-r1.eclass Alex Xu <alex_y_xu@×××××.ca>