Skip to content

Locale fallback doesn't consider Debian's /etc/default/locale #8557

@cgevans

Description

@cgevans

The resolution of #277 by commit 0a51b17 caused fish to silently set LC_CTYPE to en_US.UTF-8 if it does not get a locale from elsewhere, even if this is not a valid locale on the system.

The comment at the end of that commit suggests that the intention here was to set the character encoding to UTF-8, but on machines that don't have en_US (for example, outside of the US), it doesn't do that, and instead sets an invalid locale. This causes a number of problems (in my case, line editing and prompts broke subtly, as well as non-ASCII characters, as expected).

The commit does check for default locales in a few places, but not /etc/default/locale, the location that Debian and (I think) Ubuntu use.

My specific case here is connecting to a Debian 11 system (with en_IE.utf8), via SSH, from an Arch Linux system (which does not set SendEnv LANG LC_*, as Debian systems do).

I'm not sure what a better option is here than current behaviour, however:

  1. It would make sense to check /etc/default/locale in order to support Debian. It appears that this would only require adding it to the list of checked files.
  2. Checking locale -a to see whether en_US.UTF-8 is a supported locale before setting it might be possible, but might not be portable or cheap.
  3. Setting a hardcoded US locale when a locale is not set (and most other shells would assume C and leave the locale unset) seems surprising, and does cause problems outside the US; it might make sense to reconsider this, or warn the user.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions