From df8dbb37bbf199978680058891dfa9bbd5d90b74 Mon Sep 17 00:00:00 2001 From: Bill Nottingham Date: Wed, 4 Oct 2006 21:52:15 +0000 Subject: set iutf8 if appropriate (#186961) handle non-utf8 locales correctly (#200100) --- lang.csh | 27 ++++++++++++++++++++++++--- lang.sh | 21 ++++++++++++++++++--- 2 files changed, 42 insertions(+), 6 deletions(-) diff --git a/lang.csh b/lang.csh index 1b26d902..334a6294 100755 --- a/lang.csh +++ b/lang.csh @@ -25,6 +25,8 @@ if ($sourced == 1) then unsetenv LC_ALL endif endif + + set consoletype=`/sbin/consoletype` if ($?CHARSET) then switch ($CHARSET) @@ -36,7 +38,7 @@ if ($sourced == 1) then case latin2*: if ( $?TERM ) then if ( "$TERM" == "linux" ) then - if ( `/sbin/consoletype` == "vt" ) then + if ( "$consoletype" == "vt" ) then /bin/echo -n -e '\033(K' >/dev/tty endif endif @@ -54,7 +56,7 @@ if ($sourced == 1) then case latin2-ucw*: if ( $?TERM ) then if ( "$TERM" == "linux" ) then - if ( `/sbin/consoletype` == "vt" ) then + if ( "$consoletype" == "vt" ) then /bin/echo -n -e '\033(K' > /dev/tty endif endif @@ -66,9 +68,12 @@ if ($sourced == 1) then switch ($LANG) case *.utf8*: case *.UTF-8*: + if ( "$consoletype" == "vt" || "$consoletype" == "pty" ) then + stty iutf8 + endif if ( $?TERM ) then if ( "$TERM" == "linux" ) then - if ( `/sbin/consoletype` == "vt" ) then + if ( "$consoletype" == "vt" ) then if ( -x /bin/unicode_start ) then if { /sbin/consoletype fg } then if ( $?SYSFONT ) then @@ -84,6 +89,22 @@ if ($sourced == 1) then endif endif breaksw + case *: + if ( "$consoletype" == "vt" || "$consoletype" == "pty" ) then + stty -iutf8 + endif + if ( $?TERM ) then + if ( "$TERM" == "linux" ) then + if ( "$consoletype" == "vt" ) then + if ( -x /bin/unicode_stop ) then + if { /sbin/consoletype fg } then + /bin/unicode_stop + endif + endif + endif + endif + endif + breaksw endsw endif unsetenv SYSFONTACM diff --git a/lang.sh b/lang.sh index 6b186ce6..e8b1a911 100755 --- a/lang.sh +++ b/lang.sh @@ -40,11 +40,13 @@ if [ "$sourced" = 1 ]; then [ -n "$LANGUAGE" ] && export LANGUAGE || unset LANGUAGE [ -n "$LINGUAS" ] && export LINGUAS || unset LINGUAS [ -n "$_XKB_CHARSET" ] && export _XKB_CHARSET || unset _XKB_CHARSET + + consoletype=$(/sbin/consoletype) if [ -n "$CHARSET" ]; then case $CHARSET in 8859-1|8859-2|8859-5|8859-15|koi*) - if [ "$TERM" = "linux" -a "`/sbin/consoletype`" = "vt" ]; then + if [ "$TERM" = "linux" -a "$consoletype" = "vt" ]; then echo -n -e '\033(K' 2>/dev/null > /proc/$$/fd/0 fi ;; @@ -52,7 +54,7 @@ if [ "$sourced" = 1 ]; then elif [ -n "$SYSFONTACM" ]; then case $SYSFONTACM in iso01*|iso02*|iso05*|iso15*|koi*|latin2-ucw*) - if [ "$TERM" = "linux" -a "`/sbin/consoletype`" = "vt" ]; then + if [ "$TERM" = "linux" -a "$consoletype" = "vt" ]; then echo -n -e '\033(K' 2>/dev/null > /proc/$$/fd/0 fi ;; @@ -61,12 +63,25 @@ if [ "$sourced" = 1 ]; then if [ -n "$LANG" ]; then case $LANG in *.utf8*|*.UTF-8*) + if [ "$consoletype" = "vt" -o "$consoletype" = "pty" ]; then + stty iutf8 + fi if [ "$TERM" = "linux" ]; then - if [ "`/sbin/consoletype`" = "vt" ]; then + if [ "$consoletype" = "vt" ]; then [ -x /bin/unicode_start ] && /sbin/consoletype fg && /bin/unicode_start $SYSFONT $SYSFONTACM fi fi ;; + *) + if [ "$consoletype" = "vt" -o "$consoletype" = "pty" ]; then + stty -iutf8 + fi + if [ "$TERM" = "linux" ]; then + if [ "$consoletype" = "vt" ]; then + [ -x /bin/unicode_stop ] && /sbin/consoletype fg && /bin/unicode_stop + fi + fi + ;; esac fi -- cgit v1.2.1