DASH Shell discussions
 help / color / mirror / Atom feed
* [PATCH dash] [BUILTIN] ensure LC_COLLATE is not overriden
@ 2014-08-05 16:40 Chema Gonzalez
  2014-08-05 17:00 ` Jérémie Courrèges-Anglas
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Chema Gonzalez @ 2014-08-05 16:40 UTC (permalink / raw)
  To: Herbert Xu; +Cc: dash, Chema Gonzalez

If the user environment has either LC_ALL or LANG defined, the setting
of LC_COLLATE in src/mkbuiltins is overriden. With a non-POSIX locale,
the orders of dotcmd (remember that '.' is 0x2e in ascii) and truecmd
(':' is 0x3a in ascii) are reversed, which makes the ":" command fail
in the bsearch.

Tested:

Before this patch:

$ env |grep -e LANG -e LC_ALL
LC_ALL=en_US.ISO8859-15
LANG=en_US.iso885915
$ ./autogen.sh
...
$ ./configure
...
$ make clean; make -j 40
...
$ ./src/dash -c ":"
./src/dash: 1: :: not found
$ grep -A 3 'struct builtincmd builtincmd' src/builtins.c
const struct builtincmd builtincmd[] = {
        { ":", truecmd, 3 },
        { ".", dotcmd, 3 },
        { "[", testcmd, 0 },
$ make clean; LC_ALL= LANG= make -j 40
...
$ ./src/dash -c ":"
$ grep -A 3 'struct builtincmd builtincmd' src/builtins.c
const struct builtincmd builtincmd[] = {
        { ".", dotcmd, 3 },
        { ":", truecmd, 3 },
        { "[", testcmd, 0 },

After this patch:

env |grep -e LANG -e LC_ALL
LC_ALL=en_US.ISO8859-15
LANG=en_US.iso885915
$ ./autogen.sh
$ ./configure
...
$ make clean; make -j 40
...
$ ./src/dash -c ":"
$ grep -A 3 'struct builtincmd builtincmd' src/builtins.c
const struct builtincmd builtincmd[] = {
        { ".", dotcmd, 3 },
        { ":", truecmd, 3 },
        { "[", testcmd, 0 },

Signed-off-by: Chema Gonzalez <chema@google.com>
---
 src/mkbuiltins | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/mkbuiltins b/src/mkbuiltins
index f562ae2..ed79041 100644
--- a/src/mkbuiltins
+++ b/src/mkbuiltins
@@ -78,7 +78,7 @@ awk '{	for (i = 2 ; i <= NF ; i++) {
 		if ($i ~ /^-/)
 			line = $(++i) "\t" line
 		print line
-	}}' $temp | LC_COLLATE=C sort -k 1,1 | tee $temp2 | awk '{
+	}}' $temp | LC_ALL= LANG= LC_COLLATE=C sort -k 1,1 | tee $temp2 | awk '{
 		opt = ""
 		if (NF > 2) {
 			opt = substr($2, 2)
-- 
2.0.0.526.g5318336


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2014-08-22 23:08 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-05 16:40 [PATCH dash] [BUILTIN] ensure LC_COLLATE is not overriden Chema Gonzalez
2014-08-05 17:00 ` Jérémie Courrèges-Anglas
2014-08-05 17:11   ` Chema Gonzalez
2014-08-05 17:09 ` Eric Blake
2014-08-05 17:12   ` Chema Gonzalez
2014-08-05 17:14     ` Eric Blake
2014-08-05 17:19       ` Chema Gonzalez
2014-08-05 17:30         ` Eric Blake
2014-08-22 23:08       ` Chema Gonzalez
2014-08-22 23:08 ` [PATCH dash v2] " Chema Gonzalez

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox