]> git.ipfire.org Git - thirdparty/bash.git/commitdiff
read builtin fixes for CHERI environment; use CLOCK_GETTIME in gettimeofday replaceme...
authorChet Ramey <chet.ramey@case.edu>
Tue, 14 Oct 2025 18:21:00 +0000 (14:21 -0400)
committerChet Ramey <chet.ramey@case.edu>
Tue, 14 Oct 2025 18:21:00 +0000 (14:21 -0400)
22 files changed:
CWRU/CWRU.chlog
builtins/declare.def
builtins/mkbuiltins.c
builtins/read.def
doc/bash.0
doc/bash.1
doc/bash.html
doc/bash.pdf
examples/loadables/cat.c
execute_cmd.c
lib/readline/bind.c
lib/readline/doc/history.3
lib/readline/doc/readline.3
lib/readline/histfile.c
lib/readline/text.c
lib/sh/gettimeofday.c
redir.c
tests/glob2.sub
tests/nameref.right
tests/test-aux-functions
tests/unicode1.sub
variables.c

index 649451df392a09394be8d11cd8cbae44df7028a9..c52426545b89ee868cc33d8b377ca699bb4fed61 100644 (file)
@@ -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 <grishalevit@gmail.com>
+
+                                  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 Александр Ушаков <anushakov@edu.hse.ru>
+
+                                  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 Александр Ушаков <anushakov@edu.hse.ru>
+
+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 Александр Ушаков <anushakov@edu.hse.ru>
index b8c6f96631f53b30f35bee52c360cfd62aa8415f..9aea47c891c3d7b071ccfdfea472cc5a638c8a62 100644 (file)
@@ -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)
            {
index b39b9dd550bd483e02edc29f1bcc64daf59bd47c..2a27826fe2f189d7693db8f03bb021379019cd18 100644 (file)
@@ -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);
index 159bdb74ffabed23a02c031c6944b14c5e30c4f3..6b62d0beaf8e0abb94c45c94b7a20708dd8e9e9b 100644 (file)
@@ -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 ();
index ecb970d0fd06b67c786cb4a4bb68655b845ae880..da4d7d8fb990ea53169c10c41c37fc10e7d8c68a 100644 (file)
@@ -7514,8 +7514,8 @@ B\bBU\bUG\bG R\bRE\bEP\bPO\bOR\bRT\bTS\bS
        Once you have determined that a bug actually exists,  use  the  _\bb_\ba_\bs_\bh_\bb_\bu_\bg
        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  g\bgn\bnu\bu
-       .\b.b\bba\bas\bsh\bh.\b.b\bbu\bug\bg.
+       reports, as well as comments and bug  reports  concerning  this  manual
+       page, to to <bug-bash@gnu.org>.
 
        _\bA_\bl_\bl bug reports should include:
 
@@ -7534,26 +7534,23 @@ B\bBU\bUG\bG R\bRE\bEP\bPO\bOR\bRT\bTS\bS
        _\bb_\ba_\bs_\bh_\bb_\bu_\bg 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>.
-
 B\bBU\bUG\bGS\bS
        It's too big and too slow.
 
-       There are some subtle differences between b\bba\bas\bsh\bh and historical  versions
-       of  s\bsh\bh,  due mostly to b\bba\bas\bsh\bh's independent implementation and the evolu-
+       There  are some subtle differences between b\bba\bas\bsh\bh and historical versions
+       of s\bsh\bh, due mostly to b\bba\bas\bsh\bh'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.
index b766d08a789e1091db7b18a4cc7234f0c812d714..ab307a865b69119aae12e718785a2257303e389b 100644 (file)
@@ -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
index e05e78d63b0a9e29a4145713cc72d6436fd41058..46a6da12ae1428e3537208e737a2f99a8c579ece 100644 (file)
@@ -1,5 +1,5 @@
 <!-- Creator     : groff version 1.23.0 -->
-<!-- CreationDate: Mon Oct  6 15:30:30 2025 -->
+<!-- CreationDate: Tue Oct  7 10:14:01 2025 -->
 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 "http://www.w3.org/TR/html4/loose.dtd">
 <html>
@@ -16375,9 +16375,10 @@ and
 determined that a bug actually exists, use the
 <i>bashbug</i> command to submit a bug report. If you have a
 fix, you are encouraged to mail that as well! You may send
-suggestions and &ldquo;philosophical&rdquo; bug reports to
-<a href="mailto:bug-bash@gnu.org">bug-bash@gnu.org</a> or
-post them to the Usenet newsgroup <b>gnu.bash.bug</b>.</p>
+suggestions and &ldquo;philosophical&rdquo; bug reports, as
+well as comments and bug reports concerning this manual
+page, to to
+<a href="mailto:bug-bash@gnu.org">bug-bash@gnu.org</a>.</p>
 
 <p style="margin-left:9%; margin-top: 1em"><i>All</i> bug
 reports should include:</p>
@@ -16506,10 +16507,6 @@ the unexpected behavior.</p></td>
 inserts the first three items automatically into the
 template it provides for filing a bug report.</p>
 
-<p style="margin-left:9%; margin-top: 1em">Please send
-comments and bug reports concerning this manual page to
-<a href="mailto:bug-bash@gnu.org">bug-bash@gnu.org</a>.</p>
-
 <h2>BUGS
 <a name="BUGS"></a>
 </h2>
index ae4ffc31effd0a67ccbfe10c4278ca0b076064ef..1303fb09c3220c8f6e48546d5c4cc694ab9969c4 100644 (file)
Binary files a/doc/bash.pdf and b/doc/bash.pdf differ
index 3499755bde4b5f639d63ac2d165a839fb77951f3..a5af4ee02eec725087228efcf77a7255828fb80e 100644 (file)
@@ -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);
index 789a8b09a12e0d5dc17a9c72631b3b45eff948af..436f37ba4ef8b12a7d830542f574207689e5b041 100644 (file)
@@ -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;
index 6aaa63740eff7dd8a4dde578768aa90eea9d006f..6df5304593867183f13378b566b450c295138345 100644 (file)
@@ -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))
index 9acf75d45412556742891b5a0cb49ed59b893b95..516db9198a03a997442967368efd34511a13a298 100644 (file)
@@ -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 .
index e748f46f97190de22dcf7f4186075f9de49800df..1466b560bc68a86b99a6d9b96009bd3c8b5319b6 100644 (file)
@@ -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 .
index 235243c39e781e32369375d3cefba33f0f8a104a..f753978342b06c2d52d348dbe60a27a9c7e3fd1c 100644 (file)
@@ -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;
index 9b00a6f154607ce2767450cdba2a4bca323e143a..72baf331db15ad3c529f1d0894ce14b7d28c1d29 100644 (file)
@@ -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 &&
index 76b16573e4d01e973810f1f8e57839eca01c165b..29ed8d890be7093c8804a512b3d02680b0a236e3 100644 (file)
@@ -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 343536b7bc0f81ea0d9fecd3da73fc5572f8ce6a..3083a1633754ee51230854900d63b7a3b6fa9786 100644 (file)
--- 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;
index c52637750ee50a4c322897ba750a79ba0591f150..7c795c98e2eec7684a3c8ccd84b8e0fe5fc1c2f8 100644 (file)
 . ./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
index 19259fcedaeab93c978816ab69da370d8003555a..ec424e0f3960657faf0bbc0c9025bd873643fecd 100644 (file)
@@ -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
index 2423eebb6b7ae3d2dc1f0b7e1a26fa5dcdb0de6e..869cb3046d2f44efc7fcabc1509eba8dcbdcb229 100644 (file)
@@ -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
index 2a70247b68f7936d97e3ac130c7af9ae06b5213f..a1da45a1618dac7e363d4f36c1b2df6f344c137b 100644 (file)
@@ -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
index 214760f461d65f5743dcffc87617ab04e70ef2c3..7f1449d14ddc7c70f71bb4f7d6f7fb9b39a4519b 100644 (file)
@@ -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
        {