aboutsummaryrefslogtreecommitdiff
path: root/shell/hush.c
diff options
context:
space:
mode:
Diffstat (limited to 'shell/hush.c')
-rw-r--r--shell/hush.c33
1 files changed, 23 insertions, 10 deletions
diff --git a/shell/hush.c b/shell/hush.c
index e1d0ece29..92d790180 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -1977,6 +1977,26 @@ static struct variable *set_vars_and_save_old(char **strings)
1977 1977
1978 1978
1979/* 1979/*
1980 * Unicode helper
1981 */
1982static void reinit_unicode_for_hush(void)
1983{
1984 /* Unicode support should be activated even if LANG is set
1985 * _during_ shell execution, not only if it was set when
1986 * shell was started. Therefore, re-check LANG every time:
1987 */
1988 if (ENABLE_FEATURE_CHECK_UNICODE_IN_ENV
1989 || ENABLE_UNICODE_USING_LOCALE
1990 ) {
1991 const char *s = get_local_var_value("LC_ALL");
1992 if (!s) s = get_local_var_value("LC_CTYPE");
1993 if (!s) s = get_local_var_value("LANG");
1994 reinit_unicode(s);
1995 }
1996}
1997
1998
1999/*
1980 * in_str support 2000 * in_str support
1981 */ 2001 */
1982static int FAST_FUNC static_get(struct in_str *i) 2002static int FAST_FUNC static_get(struct in_str *i)
@@ -2042,15 +2062,7 @@ static void get_user_input(struct in_str *i)
2042 /* Enable command line editing only while a command line 2062 /* Enable command line editing only while a command line
2043 * is actually being read */ 2063 * is actually being read */
2044 do { 2064 do {
2045 /* Unicode support should be activated even if LANG is set 2065 reinit_unicode_for_hush();
2046 * _during_ shell execution, not only if it was set when
2047 * shell was started. Therefore, re-check LANG every time:
2048 */
2049 const char *s = get_local_var_value("LC_ALL");
2050 if (!s) s = get_local_var_value("LC_CTYPE");
2051 if (!s) s = get_local_var_value("LANG");
2052 reinit_unicode(s);
2053
2054 G.flag_SIGINT = 0; 2066 G.flag_SIGINT = 0;
2055 /* buglet: SIGINT will not make new prompt to appear _at once_, 2067 /* buglet: SIGINT will not make new prompt to appear _at once_,
2056 * only after <Enter>. (^C will work) */ 2068 * only after <Enter>. (^C will work) */
@@ -5028,8 +5040,9 @@ static NOINLINE const char *expand_one_var(char **to_be_freed_pp, char *arg, cha
5028 5040
5029 /* Handle any expansions */ 5041 /* Handle any expansions */
5030 if (exp_op == 'L') { 5042 if (exp_op == 'L') {
5043 reinit_unicode_for_hush();
5031 debug_printf_expand("expand: length(%s)=", val); 5044 debug_printf_expand("expand: length(%s)=", val);
5032 val = utoa(val ? strlen(val) : 0); 5045 val = utoa(val ? unicode_strlen(val) : 0);
5033 debug_printf_expand("%s\n", val); 5046 debug_printf_expand("%s\n", val);
5034 } else if (exp_op) { 5047 } else if (exp_op) {
5035 if (exp_op == '%' || exp_op == '#') { 5048 if (exp_op == '%' || exp_op == '#') {