public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
From: Mike Frysinger <vapier@gentoo.org>
To: gentoo-dev@lists.gentoo.org
Subject: [gentoo-dev] [RFC] ban use of base-4 casemods in ebuilds due to locale collation instability
Date: Tue, 10 Nov 2015 21:51:45 -0500	[thread overview]
Message-ID: <20151111025145.GU5154@vapier.lan> (raw)
In-Reply-To: <20151110235311.GR5154@vapier.lan>

[-- Attachment #1: Type: text/plain, Size: 1448 bytes --]

On 10 Nov 2015 18:53, Mike Frysinger wrote:
> i randomly stumbled across an ebuild that was using ^^ to make a variable
> uppercase.  this is new to bash-4.0 and thus invalid for EAPI=[0-5].  only
> the fresh EAPI=6 permits it since we bumped the min ver to bash-4.2.

Arfrever highlights these are not even safe to use.  bash is locale aware,
so it'll apply LC_COLLATE rules when processing the ^/, casemods.  while
you can fix this with external programs ala:
	LC_COLLATE=C tr ...

you can't do it with inline code like:
	LC_COLLATE=C SRC_URI=".../${PN^^}/..."

you can if you do something like:
	SRC_URI=".../$(LC_COLLATE=C; echo "${PN^^}")/..."

but at this point, you lose most (all?) advantage to using these in the first
place: nice & tight code.  not running tr in global scope is nice too, but it's
better all around to just hardcode something like:
	MY_PN="APINGER"
and be done with it.

thoughts ?  we could add a repoman check to detect & reject usage of it, and
for the cases where the value isn't a constant, we could add a safe helper to
eutils like:
	tolower() { LC_COLLATE=C tr '[:upper:]' '[:lower:]'; }
	toupper() { LC_COLLATE=C tr '[:lower:]' '[:upper:]'; }

yes, i'm aware that this runs the risk of mojibake when given some UTF-8
strings, but we already have that problem, and i don't think the uses so
far will hit it (as people generally feed USE flags and PN values).  it
would require the C.UTF-8 locale to address.
-mike

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

  parent reply	other threads:[~2015-11-11  2:51 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-10 23:53 [gentoo-dev] reminder: you cannot use bash-4.x features (e.g. ${var^^}) in EAPI=[0-5] Mike Frysinger
2015-11-11  1:54 ` Mike Frysinger
2015-11-11  2:51 ` Mike Frysinger [this message]
2015-11-11  4:03   ` [gentoo-dev] [RFC] ban use of base-4 casemods in ebuilds due to locale collation instability Mike Frysinger
2015-11-11  4:16   ` Ulrich Mueller
2015-11-11  7:16     ` René Neumann
2015-11-11  7:37       ` Ulrich Mueller
2015-11-11  7:47         ` Mike Frysinger
2015-11-11  8:04           ` Ulrich Mueller
2015-11-11  7:42     ` Mike Frysinger
2015-11-11  6:16   ` Patrick Lauer
2015-11-11  9:13     ` Michał Górny
2015-11-11 12:39     ` Ciaran McCreesh
2015-11-11 15:48       ` [gentoo-dev] Revise EAPI 6? (was: [RFC] ban use of base-4 casemods in ebuilds due to locale collation instability) Ulrich Mueller
2015-11-11 21:52         ` Jason A. Donenfeld
2015-11-11 22:21           ` [gentoo-dev] Revise EAPI 6? Matthias Maier
2015-11-11 23:18             ` Ulrich Mueller
2015-11-12  0:34               ` Mike Gilbert
2015-11-12  6:24                 ` Ulrich Mueller
2015-11-12  6:52           ` [gentoo-dev] Re: Revise EAPI 6? (was: [RFC] ban use of base-4 casemods in ebuilds due to locale collation instability) Martin Vaeth

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20151111025145.GU5154@vapier.lan \
    --to=vapier@gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox