chiark / gitweb /
locale-exists: New script to test whether a given locale exists on the
authorColin Watson <cjwatson@chiark.greenend.org.uk>
Thu, 16 Oct 2003 10:44:10 +0000 (10:44 +0000)
committerColin Watson <cjwatson@chiark.greenend.org.uk>
Thu, 16 Oct 2003 10:44:10 +0000 (10:44 +0000)
system.

locale-exists [new file with mode: 0755]

diff --git a/locale-exists b/locale-exists
new file mode 100755 (executable)
index 0000000..05c7e5b
--- /dev/null
@@ -0,0 +1,8 @@
+#! /bin/sh
+set -e
+
+# Takes a locale as the first argument, or assumes $LANG if there are no
+# arguments. Exits zero if the given locale exists, and non-zero otherwise.
+
+[ "$1" ] && export LANG="$1"
+PERL_BADLANG=0 perl -MPOSIX -le 'exit 1 unless setlocale(LANG, "")'