From: Chet Ramey Date: Tue, 14 Oct 2025 18:21:00 +0000 (-0400) Subject: read builtin fixes for CHERI environment; use CLOCK_GETTIME in gettimeofday replaceme... X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6a48b39bba066d6ce1e14dc86a864119aa1923d0;p=thirdparty%2Fbash.git read builtin fixes for CHERI environment; use CLOCK_GETTIME in gettimeofday replacement; readline fix to not optimize typeahead while defining a keyboard macro; fix for crash with unset nameref variable; make sure to save currently executing command around running DEBUG trap --- diff --git a/CWRU/CWRU.chlog b/CWRU/CWRU.chlog index 649451df..c5242654 100644 --- a/CWRU/CWRU.chlog +++ b/CWRU/CWRU.chlog @@ -11938,3 +11938,49 @@ builtins/read.def - read_builtin: check whether `delim' is not a newline before calling check_read_input Report from pourko2@tutamail.com + +builtins/read.def + - read_builtin: CHERI systems require that we update the unwind-protect + after every xrealloc, not just if the pointer changes + From https://savannah.gnu.org/bugs/?67586 + + 10/7 + ---- +doc/bash.1,lib/readline/doc/readline.3,lib/readline/doc/history.3 + - remove mention of Usenet and gnu.bash.bug. End of an era. + +lib/sh/gettimeofday.c + - gettimeofday: if we're replacing this function on a non-Windows + system, prefer clock_gettime (CLOCK_REALTIME, ...) if it's available + instead of just filling in the seconds from time(3) + + 10/9 + ---- +lib/readline/text.c + - rl_insert: don't try to optimize runs of typeahead characters if we + are defining a keyboard macro + Report and patch from Grisha Levit + + 10/12 + ----- +variables.c + - make_variable_value: make sure to check whether VALUE is non-NULL + before trying to strdup it; not all callers check + Report from Александр Ушаков + + 10/13riable` + ----- +builtins/declare.def + - declare_internal: if we are trying to set the attributes or value + for an unset nameref variable (attributes but no value), allow + the attribute or value setting to happen on the nameref, and don't + destroy the nameref variable on an assignment error + Report from Александр Ушаков + +execute_cmd.c + - execute_for_command,eval_arith_for_expr,execute_select_command, + execute_case_command,execute_arith_command,execute_cond_command, + execute_simple_command: save and restore currently_executing_command + around calls to run_debug_trap the same way we do it for + run_return_trap + Report from Александр Ушаков diff --git a/builtins/declare.def b/builtins/declare.def index b8c6f966..9aea47c8 100644 --- a/builtins/declare.def +++ b/builtins/declare.def @@ -775,10 +775,21 @@ restart_new_var_name: */ if (var == 0 && (mkglobal || flags_on || flags_off || offset)) { - refvar = mkglobal ? find_global_variable_last_nameref (name, 0) : find_variable_last_nameref (name, 0); + refvar = mkglobal ? find_global_variable_last_nameref (name, 1) : find_variable_last_nameref (name, 1); if (refvar && nameref_p (refvar) == 0) refvar = 0; - if (refvar) + /* If we are trying to set attributes for an unset nameref variable, + we have a couple of choices: we can set the attributes on the + nameref itself, or we can remove the nameref attribute from the + variable and treat it as an unset variable with the new + attribute(s). The former is what bash has traditionally done; the + latter is what ksh93 does. */ + if (refvar && nameref_cell (refvar) == 0) + { + var = refvar; + refvar = 0; + } + if (refvar && nameref_cell (refvar)) var = declare_find_variable (nameref_cell (refvar), mkglobal, 0); if (refvar && var == 0) { diff --git a/builtins/mkbuiltins.c b/builtins/mkbuiltins.c index b39b9dd5..2a27826f 100644 --- a/builtins/mkbuiltins.c +++ b/builtins/mkbuiltins.c @@ -525,7 +525,7 @@ extract_info (char *filename, FILE *structfile, FILE *externfile) if (stat (filename, &finfo) == -1) file_error (filename); - fd = open (filename, O_RDONLY, 0666); + fd = open (filename, O_RDONLY); if (fd == -1) file_error (filename); diff --git a/builtins/read.def b/builtins/read.def index 159bdb74..6b62d0be 100644 --- a/builtins/read.def +++ b/builtins/read.def @@ -817,7 +817,9 @@ read_builtin (WORD_LIST *list) x = (char *)xrealloc (input_string, size += 128); /* Only need to change unwind-protect if input_string changes */ +#ifndef __CHERI_PURE_CAPABILITY__ if (x != input_string) +#endif { input_string = x; remove_unwind_protect (); diff --git a/doc/bash.0 b/doc/bash.0 index ecb970d0..da4d7d8f 100644 --- a/doc/bash.0 +++ b/doc/bash.0 @@ -7514,8 +7514,8 @@ BBUUGG RREEPPOORRTTSS Once you have determined that a bug actually exists, use the _b_a_s_h_b_u_g command to submit a bug report. If you have a fix, you are encouraged to mail that as well! You may send suggestions and "philosophical" bug - reports to or post them to the Usenet newsgroup ggnnuu - ..bbaasshh..bbuugg. + reports, as well as comments and bug reports concerning this manual + page, to to . _A_l_l bug reports should include: @@ -7534,26 +7534,23 @@ BBUUGG RREEPPOORRTTSS _b_a_s_h_b_u_g inserts the first three items automatically into the template it provides for filing a bug report. - Please send comments and bug reports concerning this manual page to - . - BBUUGGSS It's too big and too slow. - There are some subtle differences between bbaasshh and historical versions - of sshh, due mostly to bbaasshh's independent implementation and the evolu- + There are some subtle differences between bbaasshh and historical versions + of sshh, due mostly to bbaasshh's independent implementation and the evolu- tion of the POSIX specification. Aliases are confusing in some uses. Shell builtin commands and functions are not stoppable/restartable. - Compound commands and command lists of the form "a ; b ; c" are not - handled gracefully when combined with process suspension. When a - process is stopped, the shell immediately executes the next command in - the list or breaks out of any existing loops. It suffices to enclose - the command in parentheses to force it into a subshell, which may be - stopped as a unit, or to start the command in the background and imme- + Compound commands and command lists of the form "a ; b ; c" are not + handled gracefully when combined with process suspension. When a + process is stopped, the shell immediately executes the next command in + the list or breaks out of any existing loops. It suffices to enclose + the command in parentheses to force it into a subshell, which may be + stopped as a unit, or to start the command in the background and imme- diately bring it into the foreground. Array variables may not (yet) be exported. diff --git a/doc/bash.1 b/doc/bash.1 index b766d08a..ab307a86 100644 --- a/doc/bash.1 +++ b/doc/bash.1 @@ -13562,13 +13562,12 @@ command to submit a bug report. If you have a fix, you are encouraged to mail that as well! You may send suggestions and .Q philosophical -bug reports to +bug reports, +as well as comments and bug reports concerning this manual page, +to +to .MT bug\-bash@\*:gnu\*:.org -.ME -or post them to the -Usenet -newsgroup -.BR gnu\*:.bash\*:.bug . +.ME . .PP .I All bug reports should include: @@ -13626,11 +13625,6 @@ exercising the unexpected behavior. .I bashbug inserts the first three items automatically into the template it provides for filing a bug report. -.PP -Please send comments and bug reports concerning -this manual page to -.MT bug\-bash@\*:gnu\*:.org -.ME . .SH BUGS It's too big and too slow. .PP diff --git a/doc/bash.html b/doc/bash.html index e05e78d6..46a6da12 100644 --- a/doc/bash.html +++ b/doc/bash.html @@ -1,5 +1,5 @@ - + @@ -16375,9 +16375,10 @@ and determined that a bug actually exists, use the bashbug command to submit a bug report. If you have a fix, you are encouraged to mail that as well! You may send -suggestions and “philosophical” bug reports to -bug-bash@gnu.org or -post them to the Usenet newsgroup gnu.bash.bug.

+suggestions and “philosophical” bug reports, as +well as comments and bug reports concerning this manual +page, to to +bug-bash@gnu.org.

All bug reports should include:

@@ -16506,10 +16507,6 @@ the unexpected behavior.

inserts the first three items automatically into the template it provides for filing a bug report.

-

Please send -comments and bug reports concerning this manual page to -bug-bash@gnu.org.

-

BUGS

diff --git a/doc/bash.pdf b/doc/bash.pdf index ae4ffc31..1303fb09 100644 Binary files a/doc/bash.pdf and b/doc/bash.pdf differ diff --git a/examples/loadables/cat.c b/examples/loadables/cat.c index 3499755b..a5af4ee0 100644 --- a/examples/loadables/cat.c +++ b/examples/loadables/cat.c @@ -84,7 +84,7 @@ cat_main (int argc, char **argv) fd = 0; closefd = 0; } else { - fd = open(argv[i], O_RDONLY, 0666); + fd = open(argv[i], O_RDONLY); if (fd < 0) { s = strerror(errno); write(2, "cat: cannot open ", 17); diff --git a/execute_cmd.c b/execute_cmd.c index 789a8b09..436f37ba 100644 --- a/execute_cmd.c +++ b/execute_cmd.c @@ -3022,6 +3022,7 @@ execute_for_command (FOR_COM *for_command) { WORD_LIST *releaser, *list; SHELL_VAR *v; + COMMAND *save_current; char *identifier; int retval, save_line_number; #if 0 @@ -3081,7 +3082,10 @@ execute_for_command (FOR_COM *for_command) the_printed_command_except_trap = savestring (the_printed_command); } + save_current = currently_executing_command; retval = run_debug_trap (); + currently_executing_command = save_current; + #if defined (DEBUGGER) /* In debugging mode, if the DEBUG trap returns a non-zero status, we skip the command. */ @@ -3188,6 +3192,7 @@ eval_arith_for_expr (WORD_LIST *l, int *okp) intmax_t expresult; int r, eflag; char *expr, *temp; + COMMAND *save_current; expr = l->next ? string_list (l) : l->word->word; temp = expand_arith_string (expr, Q_DOUBLE_QUOTES|Q_ARITH); @@ -3206,7 +3211,10 @@ eval_arith_for_expr (WORD_LIST *l, int *okp) the_printed_command_except_trap = savestring (the_printed_command); } + save_current = currently_executing_command; r = run_debug_trap (); + currently_executing_command = save_current; + #if defined (DEBUGGER) /* In debugging mode, if the DEBUG trap returns a non-zero status, we skip the command. */ @@ -3499,6 +3507,7 @@ execute_select_command (SELECT_COM *select_command) SHELL_VAR *v; char *identifier, *ps3_prompt, *selection; int retval, list_len, show_menu, save_line_number; + COMMAND *save_current; if (check_identifier (select_command->name, 1) == 0) { @@ -3526,7 +3535,10 @@ execute_select_command (SELECT_COM *select_command) the_printed_command_except_trap = savestring (the_printed_command); } + save_current = currently_executing_command; retval = run_debug_trap (); + currently_executing_command = save_current; + #if defined (DEBUGGER) /* In debugging mode, if the DEBUG trap returns a non-zero status, we skip the command. */ @@ -3640,6 +3652,7 @@ execute_case_command (CASE_COM *case_command) PATTERN_LIST *clauses; char *word, *pattern; int retval, match, ignore_return, save_line_number, qflags; + COMMAND *save_current; save_line_number = line_number; line_number = case_command->line; @@ -3657,7 +3670,10 @@ execute_case_command (CASE_COM *case_command) the_printed_command_except_trap = savestring (the_printed_command); } + save_current = currently_executing_command; retval = run_debug_trap(); + currently_executing_command = save_current; + #if defined (DEBUGGER) /* In debugging mode, if the DEBUG trap returns a non-zero status, we skip the command. */ @@ -3877,6 +3893,7 @@ execute_arith_command (ARITH_COM *arith_command) intmax_t expresult; WORD_LIST *new; char *exp, *t; + COMMAND *save_current; expresult = 0; @@ -3898,7 +3915,10 @@ execute_arith_command (ARITH_COM *arith_command) /* Run the debug trap before each arithmetic command, but do it after we update the line number information and before we expand the various words in the expression. */ + save_current = currently_executing_command; retval = run_debug_trap (); + currently_executing_command = save_current; + #if defined (DEBUGGER) /* In debugging mode, if the DEBUG trap returns a non-zero status, we skip the command. */ @@ -4113,6 +4133,7 @@ static int execute_cond_command (COND_COM *cond_command) { int retval, save_line_number; + COMMAND *save_current; save_line_number = line_number; @@ -4131,7 +4152,10 @@ execute_cond_command (COND_COM *cond_command) /* Run the debug trap before each conditional command, but do it after we update the line number information. */ + save_current = currently_executing_command; retval = run_debug_trap (); + currently_executing_command = save_current; + #if defined (DEBUGGER) /* In debugging mode, if the DEBUG trap returns a non-zero status, we skip the command. */ @@ -4455,6 +4479,7 @@ execute_simple_command (SIMPLE_COM *simple_command, int pipe_in, int pipe_out, i pid_t old_last_async_pid; sh_builtin_func_t *builtin; SHELL_VAR *func; + COMMAND *save_current; volatile int old_builtin, old_command_builtin; result = EXECUTION_SUCCESS; @@ -4484,7 +4509,10 @@ execute_simple_command (SIMPLE_COM *simple_command, int pipe_in, int pipe_out, i /* Run the debug trap before each simple command, but do it after we update the line number information. */ + save_current = currently_executing_command; result = run_debug_trap (); + currently_executing_command = save_current; + #if defined (DEBUGGER) /* In debugging mode, if the DEBUG trap returns a non-zero status, we skip the command. */ @@ -5396,13 +5424,13 @@ execute_function (SHELL_VAR *var, WORD_LIST *words, int flags, struct fd_bitmap showing_function_line = 1; save_current = currently_executing_command; result = run_debug_trap (); + currently_executing_command = save_current; #if defined (DEBUGGER) /* In debugging mode, if the DEBUG trap returns a non-zero status, we skip the command. */ if (debugging_mode == 0 || result == EXECUTION_SUCCESS) { showing_function_line = 0; - currently_executing_command = save_current; result = execute_command_internal (fc, 0, NO_PIPE, NO_PIPE, fds_to_close); /* Run the RETURN trap in the function's context */ @@ -5411,7 +5439,6 @@ execute_function (SHELL_VAR *var, WORD_LIST *words, int flags, struct fd_bitmap currently_executing_command = save_current; } #else - currently_executing_command = save_current; result = execute_command_internal (fc, 0, NO_PIPE, NO_PIPE, fds_to_close); save_current = currently_executing_command; diff --git a/lib/readline/bind.c b/lib/readline/bind.c index 6aaa6374..6df53045 100644 --- a/lib/readline/bind.c +++ b/lib/readline/bind.c @@ -967,12 +967,12 @@ _rl_read_file (char *filename, size_t *sizep) char *buffer; int i, file; - file = open (filename, O_RDONLY, 0666); + file = open (filename, O_RDONLY); /* If the open is interrupted, retry once */ if (file < 0 && errno == EINTR) { RL_CHECK_SIGNALS (); - file = open (filename, O_RDONLY, 0666); + file = open (filename, O_RDONLY); } if ((file < 0) || (fstat (file, &finfo) < 0)) diff --git a/lib/readline/doc/history.3 b/lib/readline/doc/history.3 index 9acf75d4..516db919 100644 --- a/lib/readline/doc/history.3 +++ b/lib/readline/doc/history.3 @@ -833,15 +833,8 @@ bug report to If you have a fix, you are welcome to mail that as well! Please send suggestions and .Q philosophical -bug reports to -.MT bug\-readline@\*:gnu\*:.org -.ME -or post them to the -Usenet -newsgroup -.BR gnu\*:.bash\*:.bug . -.PP -Please send comments and bug reports concerning -this manual page to +bug reports, +as well as comments and bug reports concerning this manual page, +to .MT bug\-readline@\*:gnu\*:.org .ME . diff --git a/lib/readline/doc/readline.3 b/lib/readline/doc/readline.3 index e748f46f..1466b560 100644 --- a/lib/readline/doc/readline.3 +++ b/lib/readline/doc/readline.3 @@ -1923,16 +1923,8 @@ bug report to If you have a fix, you are welcome to mail that as well! Please send suggestions and .Q philosophical -bug reports +bug reports, +as well as comments and bug reports concerning this manual page, to .MT bug\-readline@\*:gnu\*:.org -.ME -or post them to the -Usenet -newsgroup -.BR gnu\*:.bash\*:.bug . -.PP -Please send comments and bug reports concerning -this manual page to -.MT bug\-readline@\*:gnu\*:.org .ME . diff --git a/lib/readline/histfile.c b/lib/readline/histfile.c index 235243c3..f7539783 100644 --- a/lib/readline/histfile.c +++ b/lib/readline/histfile.c @@ -354,7 +354,7 @@ read_history_range (const char *filename, int from, int to) if (input == 0) return 0; errno = 0; - file = open (input, O_RDONLY|O_BINARY, 0666); + file = open (input, O_RDONLY|O_BINARY); if ((file < 0) || (fstat (file, &finfo) == -1)) goto error_and_exit; @@ -623,7 +623,7 @@ history_truncate_file (const char *fname, int lines) if (filename == 0) return 0; tempname = 0; - file = open (filename, O_RDONLY|O_BINARY, 0666); + file = open (filename, O_RDONLY|O_BINARY); rv = exists = 0; orig_lines = lines; diff --git a/lib/readline/text.c b/lib/readline/text.c index 9b00a6f1..72baf331 100644 --- a/lib/readline/text.c +++ b/lib/readline/text.c @@ -994,7 +994,7 @@ rl_insert (int count, int c) n = (unsigned short)-2; while (_rl_optimize_typeahead && rl_num_chars_to_read == 0 && - (RL_ISSTATE (RL_STATE_INPUTPENDING|RL_STATE_MACROINPUT) == 0) && + (RL_ISSTATE (RL_STATE_INPUTPENDING|RL_STATE_MACROINPUT|RL_STATE_MACRODEF) == 0) && _rl_pushed_input_available () == 0 && _rl_input_queued (0) && (n = rl_read_key ()) > 0 && diff --git a/lib/sh/gettimeofday.c b/lib/sh/gettimeofday.c index 76b16573..29ed8d89 100644 --- a/lib/sh/gettimeofday.c +++ b/lib/sh/gettimeofday.c @@ -119,6 +119,17 @@ gettimeofday (struct timeval *restrict tv, void *restrict tz) return 0; #else /* !WINDOWS_NATIVE */ +# if defined (HAVE_CLOCK_GETTIME) && defined (CLOCK_REALTIME) + struct timespec ts; + int r; + + r = clock_gettime (CLOCK_REALTIME, &ts); + if (r == 0) + { + TIMESPEC_TO_TIMEVAL(tv, &ts); + return 0; + } +# endif /* !CLOCK_GETTIME */ tv->tv_sec = (time_t) time ((time_t *)0); tv->tv_usec = 0; diff --git a/redir.c b/redir.c index 343536b7..3083a163 100644 --- a/redir.c +++ b/redir.c @@ -522,7 +522,7 @@ use_tempfile: /* In an attempt to avoid races, we close the first fd only after opening the second. */ /* Make the document really temporary. Also make it the input. */ - fd2 = open (filename, O_RDONLY|O_BINARY, 0600); + fd2 = open (filename, O_RDONLY|O_BINARY); if (fd2 < 0) { @@ -729,16 +729,6 @@ redir_open (char *filename, int flags, int mode, enum r_instruction ri) errno = e; } while (fd < 0 && errno == EINTR); - -#if 0 /* reportedly no longer needed */ -#if defined (AFS) - if ((fd < 0) && (errno == EACCES)) - { - fd = open (filename, flags & ~O_CREAT, mode); - errno = EACCES; /* restore errno */ - } -#endif /* AFS */ -#endif } return fd; diff --git a/tests/glob2.sub b/tests/glob2.sub index c5263775..7c795c98 100644 --- a/tests/glob2.sub +++ b/tests/glob2.sub @@ -14,11 +14,10 @@ . ./test-aux-functions # this locale causes problems all over the place -if locale -a | grep -i '^zh_TW\.big5' >/dev/null ; then - : -else +if [ -z "$ZH_LOCALE" ]; then echo "glob2.sub: warning: you do not have the zh_TW.big5 locale installed;" >&2 echo "glob2.sub: warning: that may cause some of these tests to fail." >&2 + ZH_LOCALE=$ZH_DEFAULT fi var='ab\' @@ -41,7 +40,7 @@ esac [[ $var = $var ]] && echo ok 4 [[ $var = $'ab\134' ]] && echo ok 5 -LC_ALL=zh_TW.big5 +LC_ALL=$ZH_LOCALE read a b c <<< $'\u3b1 b c\n' echo $b @@ -62,4 +61,4 @@ printf "%s" "a${alpha}b" | LC_ALL=C od -b | _intl_normalize_spaces a=$'\u3b1' [[ $a = $a ]] && echo ok 6 -LC_ALL=zh_TW.big5 ${THIS_SH} -c $'[[ \u3b1 = \u3b1 ]]' && echo ok 7 +LC_ALL=${ZH_LOCALE} ${THIS_SH} -c $'[[ \u3b1 = \u3b1 ]]' && echo ok 7 diff --git a/tests/nameref.right b/tests/nameref.right index 19259fce..ec424e0f 100644 --- a/tests/nameref.right +++ b/tests/nameref.right @@ -183,7 +183,7 @@ declare -n foo="bar" ./nameref11.sub: line 14: declare: `/': invalid variable name for name reference ./nameref11.sub: line 15: declare: `/': invalid variable name for name reference ./nameref11.sub: line 16: `/': not a valid identifier -./nameref11.sub: line 17: declare: `/': not a valid identifier +./nameref11.sub: line 17: declare: `/': invalid variable name for name reference ./nameref11.sub: line 18: `/': not a valid identifier 1) / #? ./nameref11.sub: line 19: `/': not a valid identifier @@ -243,12 +243,12 @@ declare -r RO2="a" declare -n r declare -a foo declare -a foo=([0]="7") -./nameref12.sub: line 39: declare: `42': not a valid identifier -./nameref12.sub: line 40: declare: x: not found +./nameref12.sub: line 39: declare: `42': invalid variable name for name reference +declare -n x declare -nr RO="foo" / -./nameref12.sub: line 58: declare: `7*6': not a valid identifier -./nameref12.sub: line 58: declare: foo: not found +./nameref12.sub: line 58: declare: `7*6': invalid variable name for name reference +declare -n foo ./nameref12.sub: line 60: `7*6': not a valid identifier declare -n ref="var" declare -n ref="var" @@ -381,6 +381,7 @@ declare -- bar ./nameref17.sub: line 28: declare: foo0: readonly variable declare -nr foo1 ./nameref17.sub: line 37: typeset: foo1: readonly variable +./nameref17.sub: line 38: typeset: foo1: readonly variable declare -nr foo1 declare -n foo2="bar" declare -r bar diff --git a/tests/test-aux-functions b/tests/test-aux-functions index 2423eebb..869cb304 100644 --- a/tests/test-aux-functions +++ b/tests/test-aux-functions @@ -19,3 +19,24 @@ test_runsub() ${THIS_SH} "$1" } + +# some useful locale variables +ZH_LOCALE=$(locale -a | grep -i '^zh_TW\.big5' | sed 1q) +ZH_DEFAULT=$(locale | grep ^LC_CTYPE | sed 's:^.*=::' | tr -d '"') + +US_LOCALE=$(locale -a | grep -i '^en_US\.utf-8' | sed 1q) +if [ -z "$US_LOCALE" ]; then + US_LOCALE=$(locale -a | grep -i '^en_US\.utf8' | sed 1q) +fi +CTYPE_DEFAULT=$ZH_DEFAULT + +# figure out default locale; use LC_CTYPE value since that is what we use it for +if [ -n "$LC_ALL" ]; then + DEFAULT_LOCALE=${LC_ALL} +elif [ -n "$LC_CTYPE" ]; then + DEFAULT_LOCALE=${LC_CTYPE} +elif [ -n "$LANG" ]; then + DEFAULT_LOCALE=${LANG} +else + DEFAULT_LOCALE="C" +fi diff --git a/tests/unicode1.sub b/tests/unicode1.sub index 2a70247b..a1da45a1 100644 --- a/tests/unicode1.sub +++ b/tests/unicode1.sub @@ -19,6 +19,8 @@ unset LC_ALL ErrorCnt=0 TestCnt=0 +. ./test-aux-functions + localewarn() { echo "unicode1.sub: warning: you do not have the $1 locale installed;" >&2 @@ -98,8 +100,9 @@ fr_FR_ISO_8859_1=( ) # this locale causes problems all over the place -if locale -a | grep -i '^fr_FR\.ISO8859.*1$' >/dev/null ; then - TestCodePage fr_FR.ISO8859-1 fr_FR_ISO_8859_1 +FR_LOCALE=$(locale -a | grep -i '^fr_FR\.ISO8859-1' | sed 1q) +if [ -n "$FR_LOCALE" ]; then + TestCodePage ${FR_LOCALE} fr_FR_ISO_8859_1 else localewarn fr_FR.ISO8859-1 @@ -118,8 +121,8 @@ zh_TW_BIG5=( ) # this locale causes problems all over the place -if locale -a | grep -i '^zh_TW\.big5' >/dev/null ; then - TestCodePage zh_TW.BIG5 zh_TW_BIG5 +if [ -n "$ZH_LOCALE" ]; then + TestCodePage $ZH_LOCALE zh_TW_BIG5 else localewarn zh_TW.BIG5 fi diff --git a/variables.c b/variables.c index 214760f4..7f1449d1 100644 --- a/variables.c +++ b/variables.c @@ -2971,7 +2971,7 @@ make_variable_value (SHELL_VAR *var, const char *value, int flags) if (value) strcpy (retval+olen, value); } - else if (*value) + else if (value && *value) retval = savestring (value); else {