diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2015-11-12 11:24:09 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2015-11-12 11:24:09 +0000 |
commit | 757c0ecefee5f43cd1dad0c570020466884aca60 (patch) | |
tree | cbb7bf85570aeecf4d83926e4df6338f91b66613 /usr.bin | |
parent | e1755278c8e7429d33cb9cb7956892ebd0377923 (diff) |
tmux is UTF-8, so if $TMUX is set (tmux running in tmux), the client is
UTF-8. Also try to make the existing checks more readable.
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/tmux/tmux.c | 40 |
1 files changed, 23 insertions, 17 deletions
diff --git a/usr.bin/tmux/tmux.c b/usr.bin/tmux/tmux.c index 578330ba58a..55c4b82b981 100644 --- a/usr.bin/tmux/tmux.c +++ b/usr.bin/tmux/tmux.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.c,v 1.151 2015/11/12 11:09:11 nicm Exp $ */ +/* $OpenBSD: tmux.c,v 1.152 2015/11/12 11:24:08 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -191,8 +191,9 @@ find_home(void) int main(int argc, char **argv) { - char *s, *path, *label, **var, tmp[PATH_MAX]; - int opt, flags, keys; + char *path, *label, **var, tmp[PATH_MAX]; + const char *s; + int opt, flags, keys; #ifdef DEBUG malloc_options = (char *) "AFGJPX"; @@ -258,20 +259,25 @@ main(int argc, char **argv) "proc exec tty ps", NULL) != 0) err(1, "pledge"); - if (!(flags & CLIENT_UTF8)) { - /* - * If the user has set whichever of LC_ALL, LC_CTYPE or LANG - * exist (in that order) to contain UTF-8, it is a safe - * assumption that either they are using a UTF-8 terminal, or - * if not they know that output from UTF-8-capable programs may - * be wrong. - */ - if ((s = getenv("LC_ALL")) == NULL || *s == '\0') { - if ((s = getenv("LC_CTYPE")) == NULL || *s == '\0') - s = getenv("LANG"); - } - if (s != NULL && (strcasestr(s, "UTF-8") != NULL || - strcasestr(s, "UTF8") != NULL)) + /* + * tmux is a UTF-8 terminal, so if TMUX is set, assume UTF-8. + * Otherwise, if the user has set LC_ALL, LC_CTYPE or LANG to contain + * UTF-8, it is a safe assumption that either they are using a UTF-8 + * terminal, or if not they know that output from UTF-8-capable + * programs may be wrong. + */ + if (getenv("TMUX") != NULL) + flags |= CLIENT_UTF8; + else { + s = getenv("LC_ALL"); + if (s == NULL || *s == '\0') + s = getenv("LC_CTYPE"); + if (s == NULL || *s == '\0') + s = getenv("LANG"); + if (s == NULL || *s == '\0') + s = ""; + if (strcasestr(s, "UTF-8") != NULL || + strcasestr(s, "UTF8") != NULL) flags |= CLIENT_UTF8; } |