From: "Kerin Millar" <kfm@plushkava.net>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/locale-gen:master commit in: /
Date: Wed, 06 Aug 2025 06:48:42 +0000 (UTC)	[thread overview]
Message-ID: <1754462770.a009d7c7ab382065555d60250752f11ef40c1c1c.kfm@gentoo> (raw)
commit:     a009d7c7ab382065555d60250752f11ef40c1c1c
Author:     Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Wed Aug  6 06:34:38 2025 +0000
Commit:     Kerin Millar <kfm <AT> plushkava <DOT> net>
CommitDate: Wed Aug  6 06:46:10 2025 +0000
URL:        https://gitweb.gentoo.org/proj/locale-gen.git/commit/?id=a009d7c7
Improve the diagnostic where /usr/share/i18n/locales cannot be entered
Consider a scenario in which locale-gen(8) is unable to switch to the
directory containing the glibc locale definition files.
# locale-gen --prefix /var/empty
sh: 1: cd: can't cd to /var/empty/usr/share/i18n/locales
locale-gen: Failed to compose a list of valid locale names from '/var/e
pty/usr/share/i18n/locales'
In this case, the implementation of sh(1) is provided by dash. I find
its diagnostic message to be lacking because it does not explain why it
cannot switch to the requested directory. That is, it could have
reported the chdir(2) error.
Address this minor issue by having the Perl interpreter attempt to
switch to the directory before executing sh(1) and find(1) and throwing
a tailored exception if it cannot.
# locale-gen --prefix /var/empty
locale-gen: Can't chdir to '/var/empty/usr/share/i18n/locales': No such
file or directory
Signed-off-by: Kerin Millar <kfm <AT> plushkava.net>
 locale-gen | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/locale-gen b/locale-gen
index 25204ca..8ee16e9 100755
--- a/locale-gen
+++ b/locale-gen
@@ -268,13 +268,16 @@ sub read_config ($prefix, @paths) {
 }
 
 sub get_valid_locales ($prefix) {
-	my $top = local $ENV{'TOP'} = catdir($prefix, '/usr/share/i18n/locales');
-	my @paths = qx{ cd -- "\$TOP" && find . ! -path . -prune ! -path '*\n*' -type f -exec grep -lxF LC_IDENTIFICATION {} + };
-	if ($? != 0 || ! @paths) {
+	my $top = catdir($prefix, '/usr/share/i18n/locales');
+	my $cmd = qq{ find . ! -path . -prune ! -path '*\n*' -type f -exec grep -lxF LC_IDENTIFICATION {} + };
+	if (! chdir $top) {
+		die "$PROGRAM: Can't chdir to '$top': $!\n";
+	} elsif (! (my @paths = readpipe $cmd) || $? != 0) {
 		die "$PROGRAM: Failed to compose a list of valid locale names from '$top'\n";
+	} else {
+		chomp @paths;
+		return map +( (splitpath($_))[-1] ), @paths;
 	}
-	chomp @paths;
-	return map +( (splitpath($_))[-1] ), @paths;
 }
 
 sub get_valid_charmaps ($prefix) {
next             reply	other threads:[~2025-08-06  6:48 UTC|newest]
Thread overview: 168+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-06  6:48 Kerin Millar [this message]
  -- strict thread matches above, loose matches on Subject: below --
2025-10-31 19:59 [gentoo-commits] proj/locale-gen:master commit in: / Kerin Millar
2025-10-28 17:16 Kerin Millar
2025-10-28 17:10 Kerin Millar
2025-10-28 17:02 Kerin Millar
2025-10-28 17:02 Kerin Millar
2025-10-28 17:02 Kerin Millar
2025-10-28 17:02 Kerin Millar
2025-10-28 17:02 Kerin Millar
2025-10-28  2:31 Kerin Millar
2025-10-28  2:10 Kerin Millar
2025-10-28  1:48 Kerin Millar
2025-10-28  0:54 Kerin Millar
2025-10-28  0:54 Kerin Millar
2025-10-28  0:54 Kerin Millar
2025-10-28  0:54 Kerin Millar
2025-10-24 14:10 Kerin Millar
2025-10-20 14:58 Kerin Millar
2025-10-20  5:13 Kerin Millar
2025-10-20  5:13 Kerin Millar
2025-10-13  4:59 Kerin Millar
2025-09-18 23:06 Kerin Millar
2025-09-18 23:04 Kerin Millar
2025-09-18 23:04 Kerin Millar
2025-09-15  5:08 Kerin Millar
2025-09-15  4:07 Kerin Millar
2025-09-15  4:07 Kerin Millar
2025-09-15  4:07 Kerin Millar
2025-09-14  4:24 Kerin Millar
2025-09-14  4:20 Kerin Millar
2025-09-13 23:53 Kerin Millar
2025-09-13 23:51 Kerin Millar
2025-09-13 23:51 Kerin Millar
2025-09-13 23:23 Kerin Millar
2025-09-13 23:23 Kerin Millar
2025-09-13  9:42 Kerin Millar
2025-09-13  9:35 Kerin Millar
2025-09-13  9:27 Kerin Millar
2025-09-13  8:46 Kerin Millar
2025-09-13  8:42 Kerin Millar
2025-09-13  1:23 Kerin Millar
2025-09-13  1:14 Kerin Millar
2025-09-12 16:59 Kerin Millar
2025-09-12 16:59 Kerin Millar
2025-09-12 16:59 Kerin Millar
2025-09-12 16:59 Kerin Millar
2025-09-12 16:59 Kerin Millar
2025-09-12 16:59 Kerin Millar
2025-08-22 23:42 Kerin Millar
2025-08-22 23:12 Kerin Millar
2025-08-22 23:12 Kerin Millar
2025-08-22 23:12 Kerin Millar
2025-08-22 23:12 Kerin Millar
2025-08-22 23:12 Kerin Millar
2025-08-22 23:12 Kerin Millar
2025-08-22 23:12 Kerin Millar
2025-08-22 23:12 Kerin Millar
2025-08-22 23:12 Kerin Millar
2025-08-22 23:12 Kerin Millar
2025-08-22 23:12 Kerin Millar
2025-08-22 23:12 Kerin Millar
2025-08-22 23:12 Kerin Millar
2025-08-20  2:39 Kerin Millar
2025-08-20  2:39 Kerin Millar
2025-08-19 13:37 Kerin Millar
2025-08-19 13:19 Kerin Millar
2025-08-18  2:46 Kerin Millar
2025-08-18  1:18 Kerin Millar
2025-08-18  1:18 Kerin Millar
2025-08-17  2:01 Kerin Millar
2025-08-16 23:17 Kerin Millar
2025-08-16 23:17 Kerin Millar
2025-08-16  3:46 Kerin Millar
2025-08-15 22:29 Kerin Millar
2025-08-15 22:29 Kerin Millar
2025-08-15 22:18 Kerin Millar
2025-08-15  5:35 Kerin Millar
2025-08-15  4:07 Kerin Millar
2025-08-15  3:57 Kerin Millar
2025-08-13 23:49 Kerin Millar
2025-08-13 22:53 Kerin Millar
2025-08-13 22:45 Kerin Millar
2025-08-13 21:42 Kerin Millar
2025-08-13 21:42 Kerin Millar
2025-08-13 21:42 Kerin Millar
2025-08-13 21:42 Kerin Millar
2025-08-13 21:42 Kerin Millar
2025-08-13 21:42 Kerin Millar
2025-08-13 10:09 Kerin Millar
2025-08-13 10:09 Kerin Millar
2025-08-12 17:32 Kerin Millar
2025-08-12  5:06 Kerin Millar
2025-08-12  5:06 Kerin Millar
2025-08-11 22:43 Kerin Millar
2025-08-11 16:04 Kerin Millar
2025-08-11 16:04 Kerin Millar
2025-08-11  0:39 Kerin Millar
2025-08-10 22:53 Kerin Millar
2025-08-10 22:22 Kerin Millar
2025-08-10 22:22 Kerin Millar
2025-08-10 17:05 Kerin Millar
2025-08-10  8:15 Kerin Millar
2025-08-10  1:22 Kerin Millar
2025-08-09 20:18 Kerin Millar
2025-08-09 19:42 Kerin Millar
2025-08-09 19:42 Kerin Millar
2025-08-09 19:42 Kerin Millar
2025-08-08 17:44 Kerin Millar
2025-08-08 17:44 Kerin Millar
2025-08-08 17:44 Kerin Millar
2025-08-08 17:44 Kerin Millar
2025-08-07 23:20 Kerin Millar
2025-08-07 23:20 Kerin Millar
2025-08-07 22:59 Kerin Millar
2025-08-07 22:59 Kerin Millar
2025-08-07 22:59 Kerin Millar
2025-08-07 22:59 Kerin Millar
2025-08-07 22:59 Kerin Millar
2025-08-07 19:43 Kerin Millar
2025-08-07 19:41 Kerin Millar
2025-08-07 19:41 Kerin Millar
2025-08-07 16:35 Kerin Millar
2025-08-07 16:20 Kerin Millar
2025-08-07 16:20 Kerin Millar
2025-08-07 16:20 Kerin Millar
2025-08-07 16:20 Kerin Millar
2025-08-07 16:20 Kerin Millar
2025-08-07 16:20 Kerin Millar
2025-08-06 17:02 Kerin Millar
2025-08-06  7:44 Kerin Millar
2025-08-05 23:00 Kerin Millar
2025-08-05 21:53 Kerin Millar
2025-08-05 21:53 Kerin Millar
2025-08-05 21:53 Kerin Millar
2025-08-05 10:55 Kerin Millar
2025-08-05 10:32 Kerin Millar
2025-08-05 10:29 Kerin Millar
2025-08-05 10:29 Kerin Millar
2025-08-04 16:02 Kerin Millar
2025-08-04 12:13 Kerin Millar
2025-08-04 12:13 Kerin Millar
2025-08-04 11:56 Kerin Millar
2025-08-04 11:25 Kerin Millar
2025-08-04 11:19 Sam James
2025-07-01 21:02 Andreas K. Hüttel
2023-05-11 22:23 Andreas K. Hüttel
2023-03-21 17:37 Andreas K. Hüttel
2021-09-27  6:49 Mike Frysinger
2021-09-27  6:49 Mike Frysinger
2021-09-27  6:49 Mike Frysinger
2021-09-27  6:49 Mike Frysinger
2021-09-27  6:49 Mike Frysinger
2021-09-27  6:49 Mike Frysinger
2021-09-27  5:46 Mike Frysinger
2021-08-06 21:09 Andreas K. Hüttel
2021-03-12 16:28 Mike Frysinger
2020-07-27 15:38 Andreas K. Hüttel
2020-07-27 10:36 Andreas K. Hüttel
2020-07-26 17:37 Andreas K. Hüttel
2020-07-26 17:37 Andreas K. Hüttel
2020-07-15  1:56 Andreas K. Hüttel
2020-07-15  1:56 Andreas K. Hüttel
2020-05-12  4:23 Andreas K. Hüttel
2020-05-12  4:23 Andreas K. Hüttel
2020-05-12  4:23 Andreas K. Hüttel
2020-05-12  4:23 Andreas K. Hüttel
2020-05-12  4:23 Andreas K. Hüttel
2020-05-12  4:23 Andreas K. Hüttel
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=1754462770.a009d7c7ab382065555d60250752f11ef40c1c1c.kfm@gentoo \
    --to=kfm@plushkava.net \
    --cc=gentoo-commits@lists.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