Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Useless `$LANG` setting in `.zshenv` #398

Closed
lunaryorn opened this Issue · 0 comments

2 participants

Sebastian Wiesner Sorin Ionescu
Sebastian Wiesner

.zshenv attempts to set $LANG from locale, which is pretty much useless.

Without arguments, locale just dumps the “current locale environment” (see locale(1)), which is essentially the contents of $LANG and all $LC_* variables. If $LANG is unset, locale doesn't output anything useful:

$ env | grep '\(LANG\|LC_.*\)'
LANG=de_DE.UTF-8
$ locale
LANG="de_DE.UTF-8"
LC_COLLATE="de_DE.UTF-8"
LC_CTYPE="de_DE.UTF-8"
LC_MESSAGES="de_DE.UTF-8"
LC_MONETARY="de_DE.UTF-8"
LC_NUMERIC="de_DE.UTF-8"
LC_TIME="de_DE.UTF-8"
LC_ALL=
$ unset LANG
$ env | grep '\(LANG\|LC_.*\)'
$ locale
LANG=
LC_COLLATE="C"
LC_CTYPE="C"
LC_MESSAGES="C"
LC_MONETARY="C"
LC_NUMERIC="C"
LC_TIME="C"
LC_ALL=

So whatever this line was conceived for, it definitely does not set $LANG. It won't even be evaluated most of the time, because $LANG is usually not empty in a decent system:

  • On OS X, Terminal.app and iTerm2 automatically export $LANG and $LC_* variables to the child shell, based on the system language settings.
  • In X11 desktops (e.g. Gnome, KDE, Unity, etc.), GUI terminals will inherit the locale environment from the Desktop environment, which in turn is either configured explicitly, or inherits the locale from the Init daemon.
  • On Unix text terminals the locale environment is inherited from the parent login process, which in turn gets the locale from the Init daemon.

The locale of the Init daemon is usually configured during system installation, and can be changed in the corresponding configuration files, whose exact locations depend on the init daemon in use (the typical Linux mess appearing here).

There are cases where $LANG is in fact empty, most notably SSH connections. However, in such cases there is no way to set $LANG automatically to a “good” value. The user has to choose $LANG manually in such case, i.e. by configuring SSH accordingly (see SendEnv/AcceptEnv, PermitUserEnvironment), or by explicitly setting $LANG to a fixed value in .zshenv or .zprofile.

TLR: Do not set $LANG from locale, and advice users to configure it manually in .zshenv.

Sorin Ionescu sorin-ionescu referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
Sorin Ionescu sorin-ionescu closed this issue from a commit
Commit has since been removed from the repository and is no longer available.
Eduardo Garcia Cebollero kiwnix referenced this issue from a commit in kiwnix/prezto
Sorin Ionescu [Fix #398] Manually set locale 93a333d
Gudleik Rasch gudleik referenced this issue from a commit in gudleik/prezto
Gudleik Rasch gudleik Merge remote-tracking branch 'upstream/master'
* upstream/master:
  Add Emacs module
  [Fix #396] Remove the osx trash function
  [Fix #398] Manually set locale
c183261
Anton Ilin bronislav referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
R Pickett emersonrp referenced this issue from a commit in emersonrp/prezto
Sorin Ionescu [Fix #398] Manually set locale 94dafba
Pavel Katsev p7k referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
Fuad Saud fuadsaud referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
Bklyn Bklyn referenced this issue from a commit in Bklyn/prezto
Caleb Epstein Merge https://github.com/sorin-ionescu/prezto into caleb
* https://github.com/sorin-ionescu/prezto:
  Add Emacs module
  [Fix #396] Remove the osx trash function
  [Fix #398] Manually set locale
  [Fix #351] Set empty keys to an invalid UTF-8 sequence
  Add support for nvm
  Use $GNUPGHOME in GPG agent startup
  [Fix #381] Remove the path_helper workaround
  [Fix #385] Do not set $INFOPATH
  [Fix #383] Do not set $MANPATH
  Fix lesspipe.sh detection in custom PATH
  [Fix #366] Distinct position with red
  Export $MANPATH and $INFOPATH
  [Fix #349] Display diff when committing
  [Fix #360] Set alias giR to reset the index interactively
  [Fix #357] Set alias gcO to check out hunks interactively
  [Fix #355] Do not set launchd environment variables
157ae44
Jon Duell duellj referenced this issue from a commit in duellj/prezto
Jon Duell duellj Merge remote-tracking branch 'upstream/master'
* upstream/master:
  Set WORDCHARS in the editor module
  [Fix #422] Revert "Remove no longer necessary key bindings"
  Update external history-substring-search
  Sort Git conflict aliases
  [Fix #403] Display accented characters properly
  Correct typos in git module README
  Wrap errant long line in git module README
  Fix misspellings of the word bellow in READMEs
  Remove no longer necessary key bindings
  Update external history-substring-search
  Update external syntax-highlighting
  Update external completions
  [Fix #399] Only enable the main syntax highlighter
  Use the builtin $signals array
  Add Emacs module
  [Fix #396] Remove the osx trash function
  [Fix #398] Manually set locale

Conflicts:
	runcoms/zpreztorc
168d98f
Stephen Lumenta sbl referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
Adam Walz adamwalz referenced this issue from a commit in adamwalz/prezto
Sorin Ionescu [Fix #398] Manually set locale 848ef54
Mitchell Garvin phddoom referenced this issue from a commit in phddoom/prezto
Sorin Ionescu [Fix #398] Manually set locale 5d850b0
Adam Walz adamwalz referenced this issue from a commit in adamwalz/prezto
Sorin Ionescu [Fix #398] Manually set locale 0528fed
Linus Lundahl linuslundahl referenced this issue from a commit in linuslundahl/prezto
Sorin Ionescu [Fix #398] Manually set locale 9a4d821
Colin Seymour lildude referenced this issue from a commit in lildude/prezto
Sorin Ionescu [Fix #398] Manually set locale 0074d31
László Bácsi lackac referenced this issue from a commit in lackac/prezto
Sorin Ionescu [Fix #398] Manually set locale 8037a8a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.