mirror of
https://github.com/systemd/systemd
synced 2024-09-16 06:43:18 +00:00
basic: do not output emojis if not on a proper terminal
$TERM would generally be set if we're connected to a proper graphical terminal emulator. In all other cases, in particular if $TERM is not set, we almost certainly are not connected to something that can output emojis. In particular the text console is unlikely to ever do it correctly. So let's invert the check, and only write emojis if $TERM is set. Fixes #25521.
This commit is contained in:
parent
60e84f0205
commit
7a14db9cfd
|
@ -9,15 +9,15 @@ bool emoji_enabled(void) {
|
|||
static int cached_emoji_enabled = -1;
|
||||
|
||||
if (cached_emoji_enabled < 0) {
|
||||
int val;
|
||||
int val = getenv_bool("SYSTEMD_EMOJI");
|
||||
if (val >= 0)
|
||||
return (cached_emoji_enabled = val);
|
||||
|
||||
val = getenv_bool("SYSTEMD_EMOJI");
|
||||
if (val < 0)
|
||||
cached_emoji_enabled =
|
||||
is_locale_utf8() &&
|
||||
!STRPTR_IN_SET(getenv("TERM"), "dumb", "linux");
|
||||
else
|
||||
cached_emoji_enabled = val;
|
||||
const char *term = getenv("TERM");
|
||||
if (!term || STR_IN_SET(term, "dumb", "linux"))
|
||||
return (cached_emoji_enabled = false);
|
||||
|
||||
cached_emoji_enabled = is_locale_utf8();
|
||||
}
|
||||
|
||||
return cached_emoji_enabled;
|
||||
|
|
Loading…
Reference in a new issue