Swordfish90 / cool-retro-term

A good looking terminal emulator which mimics the old cathode display...
21.76k stars 836 forks source link

LC_CTYPE=UTF causes libreadline applications to crash due to invalid locale on non-Ubuntu systems #840

Open NCommander opened 2 months ago

NCommander commented 2 months ago

cool-retro-term, at least on macOS, sets LC_FTYPE to UTF-8, and no other locale information. This is an invalid locale (it should be unset, or set to 'C'), but it has a rather disastrous interaction with programs compiled against older versions of readline that have NLS enabled

LANGUAGE=''
LC_CTYPE=UTF-8

This causes bash on illumos to crash when logging via SSH (https://github.com/omniosorg/omnios-build/issues/3537#event-12361550471), which took an extended effort to debug and find. The issue is in most versions of libreadline, but has been patched upstream at this point.

Ubuntu has a special script, /etc/profile.d/01-locale-fix.sh which resets the locale to something valid which prevents this issue from cropping up there.

The problem in cool-retro-term is here: https://github.com/Swordfish90/qmltermwidget/blob/63228027e1f97c24abb907550b22ee91836929c5/src/ksession.cpp#L84

On Linux, it should probably just accept whatever LC_* it gets from the login environment as is. That said, setting LC_CTYPE only affects the output of tolower() , toupper() and isalpha(), and a few other functions, and its usually errorous to set it without other locale information.