Generation of locales: made call to tr more robust and added LOWERCASE macro
authorThierry Bultel <thierry.bultel@wanadoo.fr>
Sun, 10 Nov 2013 17:32:52 +0000 (18:32 +0100)
committerPeter Korsgaard <peter@korsgaard.com>
Sun, 10 Nov 2013 22:41:28 +0000 (23:41 +0100)
When calling 'tr' without quoting braces, bash can make really weird things
if there are existing 'single-letter-named' directories
eg:
thierry@thierry-desktop:~$ echo AAA | tr [A-Z] [a-z]
aaa
thierry@thierry-desktop:~$ mkdir m
thierry@thierry-desktop:~$ echo AAA | tr [A-Z] [a-z]
AAA

The (quick) analysis is that the callee (tr) argvs then
contain 'm' thus the translation does not work

Using quotes works around it:
thierry@thierry-desktop:~$ echo AAA | tr '[A-Z]' '[a-z]'
aaa

Signed-off-by: Thierry Bultel <thierry.bultel@wanadoo.fr>
Reviewed-by: Thomas De Schampheleire <thomas.de.schampheleire@gmail.com>
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
Makefile
package/pkg-utils.mk

index 1496bd74fca0da8b5a5f455b9e1bc100d0eb8385..a006615f76b4f7d38596358eb05b7b962da4616e 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -548,7 +548,7 @@ target-generatelocales: host-localedef
                I18NPATH=$(STAGING_DIR)/usr/share/i18n:/usr/share/i18n \
                $(HOST_DIR)/usr/bin/localedef \
                        --prefix=$(TARGET_DIR) \
-                       --`echo $(BR2_ENDIAN) | tr [A-Z] [a-z]`-endian \
+                       --$(call LOWERCASE,$(BR2_ENDIAN))-endian \
                        -i $${inputfile} -f $${charmap} \
                        $${locale} ; \
        done
index 5930f2cfc29ef64f28992d4ea9c64f4df3151f89..0ef433dc9307eb5274b82cbc8872a9c56fd91ed6 100644 (file)
@@ -23,6 +23,14 @@ UPPERCASE = $(strip $(eval __tmp := $1) \
        $(__tmp)))) \
        $(__tmp))
 
+# LOWERCASE macro -- transforms its arguments to lowercase
+# The above non-tr implementation is not needed, because LOWERCASE is not
+# called very often
+
+define LOWERCASE
+$(shell echo $1 | tr '[:upper:]' '[:lower:]')
+endef
+
 #
 # Manipulation of .config files based on the Kconfig
 # infrastructure. Used by the Busybox package, the Linux kernel