commit: 203663d37bec377cfe49fe45abc05cfd520af3a1
Author: Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Thu Aug 7 23:15:47 2025 +0000
Commit: Kerin Millar <kfm <AT> plushkava <DOT> net>
CommitDate: Thu Aug 7 23:16:39 2025 +0000
URL: https://gitweb.gentoo.org/proj/locale-gen.git/commit/?id=203663d3
Allow for options to be parsed before aborting for a foreign libc
It should always be possible for the -h and -V options to be honoured,
irrespective of whether the platform is compatible with locale-gen(8).
Make it so.
Signed-off-by: Kerin Millar <kfm <AT> plushkava.net>
locale-gen | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/locale-gen b/locale-gen
index 6dc7ad3..7c87e79 100755
--- a/locale-gen
+++ b/locale-gen
@@ -47,15 +47,23 @@ umask 0022;
my $locale_dir = get_locale_dir();
# Infer the path of a Gentoo Prefix environment, if any.
- my $gentoo_prefix = detect_gentoo_prefix($locale_dir);
- if (length $gentoo_prefix) {
- $locale_dir =~ s/^\Q$gentoo_prefix//;
+ my $gentoo_prefix = '';
+ if (defined $locale_dir) {
+ $gentoo_prefix = detect_gentoo_prefix($locale_dir);
+ if (length $gentoo_prefix) {
+ $locale_dir =~ s/^\Q$gentoo_prefix//;
+ }
}
# Collect any supported options and option-arguments.
my %opt = parse_opts($gentoo_prefix, @ARGV);
my $prefix = $opt{'prefix'} // $gentoo_prefix;
+ # For the directory to be unknown strongly implies the absence of glibc.
+ if (! defined $locale_dir) {
+ die "$PROGRAM: Aborting because the OS does not appear to use
GNU libc\n";
+ }
+
# Honour the --quiet option.
if ($opt{'quiet'} && ! open *STDOUT, '>/dev/null') {
die "Can't direct STDOUT to /dev/null: $!";
@@ -128,7 +136,7 @@ sub get_locale_dir () {
return canonpath($1);
} elsif (($? & 0xFF) == 0) {
# The child terminated normally (in the sense of WIFEXITED).
- die "$PROGRAM: Aborting because the OS does not appear to use
GNU libc\n";
+ return undef;
} else {
throw_child_error('localedef');
}