BTS

Issue706

Title zshrc: xsource "/etc/default/locale" overrides environment
Priority bug Status resolved
Superseder Nosy List ft, mika
Assigned To ft Topics release-stopper

Created on 2009-07-07.20:02:45 by mika, last changed 2009-07-28.16:01:13 by mika.

Messages
msg2363 (view) Author: mika Date: 2009-07-28.16:01:08
We believe that your issue has been closed by the upload of
Version 0.3.73 of grml-etc-core from Michael Prokop <mika@grml.org>.
The explanation is attached below

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Format: 1.8
Date: Tue, 28 Jul 2009 17:53:08 +0200
Source: grml-etc-core
Binary: grml-etc-core
Architecture: source all
Version: 0.3.73
Distribution: unstable
Urgency: low
Maintainer: Michael Prokop <mika@grml.org>
Changed-By: Michael Prokop <mika@grml.org>
Description: 
 grml-etc-core - core ecetera files for the grml system
Changes: 
 grml-etc-core (0.3.73) unstable; urgency=low
 .
   [ Frank Terbeck ]
   * zshrc: Fix a problem when calling compinit can seem to cause zsh startup
     to hang forever. Reported by Rasmus Steinke.
   * zshrc: Fix problems related to TERM=mostlike in zshrc. Again reported by
     Rasmus Steinke.
   * zshrc: Give check_com a -g option to test for global aliases, too.
   * zshrc: Get rid of whence, once and for all.
   * zshrc: Insert a condition for loading /etc/default/locale
     [Closes: issue706]
   * zshrc: Set options a lot earlier and include noshwordsplit explicitly.
   * zshrc: Make functions insusceptible to user option settings.
   * zsh: move completion.d and functions.d to usr/share
   * zshrc: Include the current directory in the persistent directory stack.
 .
   [ Michael Prokop ]
   * zshrc: add deborphan, pal and hnb to compdef _gnu_generic. Thanks for
     the suggestion to Carsten Hey.
   * Drop all 'Latest Change' leftover references in several config files.
   * Minor Debian packaging updates (to make recent lintian versions happy):
     - update Standard version to 3.8.2
     - depend on debhelper >= 5
     - don't call true binary with full path in preinst script
     - update debian/overrides
Checksums-Sha1: 
 36475b8d9f7b4f21b952cbc2935375f45d98f1bc 869 grml-etc-core_0.3.73.dsc
 66ab9f6c593d56b9b8c990b4aa6dad1504a8ffee 114893 grml-etc-core_0.3.73.tar.gz
 c82c5dc7852bd1ff418dcc6967cd44d0a3bdc776 118550 grml-etc-core_0.3.73_all.deb
Checksums-Sha256: 
 03e1cd205dd5c5efd439c5a00e83518b5e54b6fca045f5419f539775727807cb 869 grml-etc-core_0.3.73.dsc
 5c8a66331a4f80798098b72a753665dc5b20eeef4a1f6418b5345e0f11e29ffd 114893 grml-etc-core_0.3.73.tar.gz
 a0da3e6dce1d07fa1f44dd7f46936a74ddef668698088637e07b6ccaaf2fd507 118550 grml-etc-core_0.3.73_all.deb
Files: 
 1d286ca9fc0c5ecc866ebb8c63f34a4e 869 grml optional grml-etc-core_0.3.73.dsc
 be82d4ce1614e6a760f13af07f71ee5e 114893 grml optional grml-etc-core_0.3.73.tar.gz
 8d5b9e94b0e70b3d329c7718b8eb9464 118550 grml optional grml-etc-core_0.3.73_all.deb

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iD8DBQFKbx9u2N9T+zficugRAiKeAJ9vlH8YM+gmGaQrEXong+oPgA3/fwCffHqk
gsM3fyvnkrE/7Q72eslow70=
=88Br
-----END PGP SIGNATURE-----
msg2348 (view) Author: mika Date: 2009-07-08.11:05:49
* Frank Terbeck <ft@bewatermyfriend.org> [20090708 12:56]:
> Michael Prokop <bts@bts.grml.org>:

[...]

> And FWIW, I think ZSH_NO_DEFAULT_LOCALE is a good name.

> The fix would look like this:

[...]

> iso-term would need to inject ZSH_NO_DEFAULT_LOCALE=1 into its
> environment.

Applied and tested: works fine.

> Please ACK this and I'll push with an appropriate commit message.

ACK

Thanks!

regards,
-mika-
msg2347 (view) Author: ft Date: 2009-07-08.10:57:59
Frank Terbeck <ft@bewatermyfriend.org>:
> -xsource "/etc/default/locale"
> +if (( ZSH_NO_DEFAULT_LOCALE == 0 )); then
> +    echo ping

Obviously this is test code, which won't make it into the commit. :)

> +    xsource "/etc/default/locale"
> +fi
msg2346 (view) Author: ft Date: 2009-07-08.10:56:59
Michael Prokop <bts@bts.grml.org>:
> Alright, discussing this issue in #grml Thorsten 'mira' Glaser
> brought up the following idea:
> 
> * do not source /etc/default/locale if something like
>   $ZSH_NO_DEFAULT_LOCALE is set
> * $ZSH_NO_DEFAULT_LOCALE isn't set by default, but:
> * iso-term can set $ZSH_NO_DEFAULT_LOCALE and avoid sourcing
>   /etc/default/ locale via /etc/zsh/zshrc therefore
> 
> This should prevent us from yet another change in the locale hell.
> 
> Frank, what do you think?

Since this is pretty much what I was after:
    ft » mika: kannst du steuern, wie iso-term die zsh startet?
    [...]
    mika » ft: grml-skript, das einfach utf-8 in iso wandelt im
           environment:
    [...]
    ft » mika: dann könnte man darin eine Variable setzen, die das
         Laden von default/locale verhindert. (was die Sache in der
         zshrc wieder komplizierter macht, aber hey. :))

And FWIW, I think ZSH_NO_DEFAULT_LOCALE is a good name.

The fix would look like this:

[snip]
diff --git a/etc/zsh/zshrc b/etc/zsh/zshrc
index 43dab29..5527ec8 100644
--- a/etc/zsh/zshrc
+++ b/etc/zsh/zshrc
@@ -252,6 +252,7 @@ GRML_ZSH_CNF_HANDLER=${GRML_ZSH_CNF_HANDLER:-/usr/share/command-not-found/comman
 BATTERY=${BATTERY:-0}
 GRMLSMALL_SPECIFIC=${GRMLSMALL_SPECIFIC:-1}
 GRML_ALWAYS_LOAD_ALL=${GRML_ALWAYS_LOAD_ALL:-0}
+ZSH_NO_DEFAULT_LOCALE=${ZSH_NO_DEFAULT_LOCALE:-0}
 
 if isgrmlcd ; then
     GRML_WARN_SKEL=${GRML_WARN_SKEL:-0}
@@ -483,7 +484,10 @@ zrclocal() {
 #}}}
 
 # locale setup {{{
-xsource "/etc/default/locale"
+if (( ZSH_NO_DEFAULT_LOCALE == 0 )); then
+    echo ping
+    xsource "/etc/default/locale"
+fi
 
 for var in LANG LC_ALL LC_MESSAGES ; do
     [[ -n ${(P)var} ]] && export $var
[snap]

iso-term would need to inject ZSH_NO_DEFAULT_LOCALE=1 into its
environment.

Please ACK this and I'll push with an appropriate commit message.

Regards, Frank
msg2343 (view) Author: mika Date: 2009-07-07.22:14:34
Alright, discussing this issue in #grml Thorsten 'mira' Glaser brought up the 
following idea:

* do not source /etc/default/locale if something like $ZSH_NO_DEFAULT_LOCALE is 
set
* $ZSH_NO_DEFAULT_LOCALE isn't set by default, but:
* iso-term can set $ZSH_NO_DEFAULT_LOCALE and avoid sourcing /etc/default/
locale via /etc/zsh/zshrc therefore

This should prevent us from yet another change in the locale hell.

Frank, what do you think?

regards,
-mika-
msg2342 (view) Author: ft Date: 2009-07-07.20:51:57
Michael Prokop <bts@bts.grml.org>:
> The following snippet in zshrc causes iso-term to fail:
> 
> xsource "/etc/default/locale"
> for var in LANG LC_ALL LC_MESSAGES ; do
>     [[ -n ${(P)var} ]] && export $var
> done
> 
> iso-term tries to replace UTF-8 in the environment with iso885915 (useful if 
> you have to edit iso88591 encoded documents in the shell) but as the global 
> zshrc sources /etc/default/locale and exports environment variables again this 
> doesn't have any effect.

Well well well. If it's not locale hell all over again.
I _so_ hate it... :-/

Anyway, git blame says I introduced this in git commit
76706fcdd9c160d7f3212e597d2139f45531da72 - and I think I did it
because someone (gebi?) asked for it.

The Changelog entry (and I had to look at the changelog, because my
git commit message is a pile of crap...) says:

    Always read /etc/default/locale. Users are expected to adjust
    locale settings via '.zshrc.local'.

And I think that's still correct. If your system is UTF8 by default,
we should just take that. If the user wants ISO, he/she should set
their shell up for it.

Regards, Frank
msg2341 (view) Author: mika Date: 2009-07-07.20:02:43
The following snippet in zshrc causes iso-term to fail:

xsource "/etc/default/locale"
for var in LANG LC_ALL LC_MESSAGES ; do
    [[ -n ${(P)var} ]] && export $var
done

iso-term tries to replace UTF-8 in the environment with iso885915 (useful if 
you have to edit iso88591 encoded documents in the shell) but as the global 
zshrc sources /etc/default/locale and exports environment variables again this 
doesn't have any effect.

Frank, do you have any ideas for an elegant solution? :)

regards,
-mika-
History
Date User Action Args
2009-07-28 16:01:13mikasetstatus: fixed-in-git -> resolved
nosy: mika, ft
messages: + msg2363
2009-07-08 11:21:38ftsetstatus: chatting -> fixed-in-git
nosy: mika, ft
2009-07-08 11:05:50mikasetnosy: mika, ft
messages: + msg2348
2009-07-08 10:57:59ftsetnosy: mika, ft
messages: + msg2347
2009-07-08 10:57:04ftsetnosy: mika, ft
messages: + msg2346
2009-07-07 22:14:37mikasetnosy: mika, ft
messages: + msg2343
2009-07-07 20:51:58ftsetstatus: unread -> chatting
nosy: mika, ft
messages: + msg2342
2009-07-07 20:02:45mikacreate