ensure LC_COLLATE is not overriden
PATCH 1/1 ensure LC_COLLATE is not overriden
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 },--- src/mkbuiltins | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
src/mkbuiltins +1 -1
@@ -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)
Signature · 1 line
2.0.0.526.g5318336
Quoted 5 lines · Chema Gonzalez
If the user environment has either
LC_ALLor LANG defined, the setting ofLC_COLLATEin src/mkbuiltins is overriden. With a non-POSIX locale, the orders of dotcmd (remember that '.' is0x2ein ascii) and truecmd (':' is0x3ain ascii) are reversed, which makes the ":" command fail in the bsearch.
Actually the problem should only occur when you set LC_ALL, which overrides LANG and LC_COLLATE. Even though some may find nice to protect the unwary, but I'd expect lots of brokenness in this unusual build situation, and this not limited to dash.
Signature · 1 line
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF DDCC 0DFA 74AE 1524 E7EE
src/mkbuiltins awk '{ for (i = 2 ; i <= NF ; i++) { · line 81
Quoted 9 lines · Chema Gonzalez
If the user environment has either
LC_ALLor LANG defined, the setting ofLC_COLLATEin src/mkbuiltins is overriden. With a non-POSIX locale, the orders of dotcmd (remember that '.' is0x2ein ascii) and truecmd (':' is0x3ain ascii) are reversed, which makes the ":" command fail in the bsearch.src/mkbuiltins +1
-1- }}' $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 '{
Setting LC_ALL= to the empty string risks implementation-defined behavior. Also, LC_ALL overrides LANG and LC_COLLATE. It should be sufficient to merely do:
}}' $temp | LC_ALL=C sort -k 1,1 | tee $temp2 | awk '{Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Quoted 2 lines · Jérémie Courrèges-Anglas
Actually the problem should only occur when you set
LC_ALL, which overrides LANG andLC_COLLATE. Even though some may find nice to
My FreeBSD notes (they may be really stale) state LANG overrides LC_ALL in FreeBSD (4.x). If that's correct, we need to take care of both.
Quoted 2 lines
protect the unwary, but I'd expect lots of brokenness in this unusual build situation, and this not limited to dash.
-Chema
Quoted 3 lines
--
jca | PGP :0x1524E7EE/ 5135 92C1 AD36 5293 2BDF DDCC 0DFA 74AE 1524 E7EE
Quoted 8 lines · Eric Blake
Quoted 6 lines · Chema Gonzalez
If the user environment has either
LC_ALLor LANG defined, the setting ofLC_COLLATEin src/mkbuiltins is overriden. With a non-POSIX locale, the orders of dotcmd (remember that '.' is0x2ein ascii) and truecmd (':' is0x3ain ascii) are reversed, which makes the ":" command fail in the bsearch.
Quoted 8 lines
src/mkbuiltins awk '{ for (i = 2 ; i <= NF ; i++) { · line 81
Quoted 2 lines
src/mkbuiltins +1
-1- }}' $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 '{Setting LC_ALL= to the empty string risks implementation-defined behavior. Also,
LC_ALLoverrides LANG andLC_COLLATE. It should be sufficient to merely do:}}' $temp | LC_ALL=C sort -k 1,1 | tee $temp2 | awk '{
Maybe:
}}' $temp | LC_ALL=C LANG=C sort -k 1,1 | tee $temp2 | awk '{-Chema
Quoted 5 lines
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
Quoted 8 lines · Chema Gonzalez
Quoted 5 lines
Setting LC_ALL= to the empty string risks implementation-defined behavior. Also,
LC_ALLoverrides LANG andLC_COLLATE. It should be sufficient to merely do:}}' $temp | LC_ALL=C sort -k 1,1 | tee $temp2 | awk '{Maybe:
}}' $temp | LC_ALL=C LANG=C sort -k 1,1 | tee $temp2 | awk '{
No need to specify LANG=C when LC_ALL is set. I stand by my shorter line.
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Quoted 11 lines · Eric Blake
Quoted 8 lines · Chema Gonzalez
Quoted 5 lines
Setting LC_ALL= to the empty string risks implementation-defined behavior. Also,
LC_ALLoverrides LANG andLC_COLLATE. It should be sufficient to merely do:}}' $temp | LC_ALL=C sort -k 1,1 | tee $temp2 | awk '{Maybe:
}}' $temp | LC_ALL=C LANG=C sort -k 1,1 | tee $temp2 | awk '{No need to specify LANG=C when
LC_ALLis set. I stand by my shorter line.
I'd prefer to see if any FreeBSD user can confirm whether LC_ALL overrides LANG (as in Linux) or the other way around. The docs seems to suggest to use LANG instead of LC_ALL there.
http://www.freebsd.org/doc/handbook/using-localization.html
-Chema
Quoted 5 lines
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
Quoted 8 lines · Chema Gonzalez
Quoted 7 lines · Eric Blake
Quoted 6 lines · Chema Gonzalez
Quoted 5 lines
Setting LC_ALL= to the empty string risks implementation-defined behavior. Also,
LC_ALLoverrides LANG andLC_COLLATE. It should be sufficient to merely do:}}' $temp | LC_ALL=C sort -k 1,1 | tee $temp2 | awk '{
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Maybe:
}}' $temp | LC_ALL=C LANG=C sort -k 1,1 | tee $temp2 | awk '{No need to specify LANG=C when
LC_ALLis set. I stand by my shorter line.I'd prefer to see if any FreeBSD user can confirm whether
LC_ALLoverrides LANG (as in Linux) or the other way around. The docs seems to suggest to use LANG instead ofLC_ALLthere.
Bug in the docs, then, as POSIX is quite clear that LC_ALL overrides LC_* overrides LANG. If FreeBSD ever got it backwards, even temporarily, from what POSIX requires, it would be a lot more obvious.
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
I finally managed to test a FreeBSD 10.0 host, and it seems to respect LC_ALL before LANG.
Next patch includes just setting LC_ALL (which trumps LC_COLLATE).
-Chema
Quoted 16 lines · Eric Blake
Quoted 8 lines · Chema Gonzalez
Quoted 5 lines
Setting LC_ALL= to the empty string risks implementation-defined behavior. Also,
LC_ALLoverrides LANG andLC_COLLATE. It should be sufficient to merely do:}}' $temp | LC_ALL=C sort -k 1,1 | tee $temp2 | awk '{Maybe:
}}' $temp | LC_ALL=C LANG=C sort -k 1,1 | tee $temp2 | awk '{No need to specify LANG=C when
LC_ALLis set. I stand by my shorter line.--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
PATCH v2 1/1 ensure LC_COLLATE is not overriden
In reply to Chema GonzalezIf 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 },--- src/mkbuiltins | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
src/mkbuiltins +1 -1
@@ -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=C sort -k 1,1 | tee $temp2 | awk '{ opt = "" if (NF > 2) { opt = substr($2, 2)
Signature · 1 line
2.1.0.rc2.206.gedb03e5