From 9508f8c05cc13ef2df7fa11304e25688b8c4c882 Mon Sep 17 00:00:00 2001 From: Yuri Pankov Date: Sun, 4 Nov 2018 16:58:55 +0000 Subject: [PATCH] Teach man(1) about C.UTF-8. While here, use LANG as the proper source to select man pages language/encoding, falling back to LC_CTYPE. Reviewed by: bapt Approved by: kib (mentor, implicit) Differential Revision: https://reviews.freebsd.org/D17835 --- usr.bin/man/man.sh | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/usr.bin/man/man.sh b/usr.bin/man/man.sh index a71ac3578d30..12a370cd8efb 100755 --- a/usr.bin/man/man.sh +++ b/usr.bin/man/man.sh @@ -662,6 +662,7 @@ man_setup_width() { # Setup necessary locale variables. man_setup_locale() { local lang_cc + local locstr locpaths='.' man_charset='US-ASCII' @@ -670,18 +671,25 @@ man_setup_locale() { if [ -n "$oflag" ]; then decho 'Using non-localized manpages' else - # Use the locale tool to give us the proper LC_CTYPE + # Use the locale tool to give us proper locale information eval $( $LOCALE ) - case "$LC_CTYPE" in + if [ -n "$LANG" ]; then + locstr=$LANG + else + locstr=$LC_CTYPE + fi + + case "$locstr" in C) ;; + C.UTF-8) ;; POSIX) ;; [a-z][a-z]_[A-Z][A-Z]\.*) - lang_cc="${LC_CTYPE%.*}" - man_lang="${LC_CTYPE%_*}" + lang_cc="${locstr%.*}" + man_lang="${locstr%_*}" man_country="${lang_cc#*_}" - man_charset="${LC_CTYPE#*.}" - locpaths="$LC_CTYPE" + man_charset="${locstr#*.}" + locpaths="$locstr" locpaths="$locpaths:$man_lang.$man_charset" if [ "$man_lang" != "en" ]; then locpaths="$locpaths:en.$man_charset"