X-Git-Url: https://hackdaworld.org/gitweb/?p=hdw-linux%2Fhdw-linux.git;a=blobdiff_plain;f=packages%2Fbase%2Fbash%2Fofficial_fixes.patch;fp=packages%2Fbase%2Fbash%2Fofficial_fixes.patch;h=7aed9e8428fc2277572c015422f082f0f526f027;hp=9f314eece51465c1ed801cafad6425291888b39e;hb=793f79d0d200544e7193cdfd4b66dc2479bf7247;hpb=504579d0d381b02fc33fe1c696d64f96135a15a8 diff --git a/packages/base/bash/official_fixes.patch b/packages/base/bash/official_fixes.patch index 9f314ee..7aed9e8 100644 --- a/packages/base/bash/official_fixes.patch +++ b/packages/base/bash/official_fixes.patch @@ -1,703 +1,701 @@ -diff -Naur bash-3.0.orig/array.c bash-3.0/array.c ---- bash-3.0.orig/array.c 2004-05-06 12:24:13.000000000 +0000 -+++ bash-3.0/array.c 2005-01-08 05:40:02.059798512 +0000 -@@ -451,7 +451,7 @@ - */ - array_dispose_element(new); - free(element_value(ae)); -- ae->value = savestring(v); -+ ae->value = v ? savestring(v) : (char *)NULL; - return(0); - } else if (element_index(ae) > i) { - ADD_BEFORE(ae, new); -diff -Naur bash-3.0.orig/arrayfunc.c bash-3.0/arrayfunc.c ---- bash-3.0.orig/arrayfunc.c 2003-12-19 05:03:09.000000000 +0000 -+++ bash-3.0/arrayfunc.c 2005-01-08 05:40:01.679856272 +0000 -@@ -611,7 +611,7 @@ - var = find_variable (t); - +--- bash-3.1.orig/arrayfunc.c 2005-07-04 17:25:58.000000000 -0700 ++++ bash-3.1/arrayfunc.c 2006-04-19 15:59:29.000000000 -0700 +@@ -592,11 +592,7 @@ + exp = (char *)xmalloc (len); + strncpy (exp, s, len - 1); + exp[len - 1] = '\0'; +-#if 0 +- t = expand_string_to_string (exp, 0); +-#else +- t = expand_string_to_string (exp, Q_DOUBLE_QUOTES); +-#endif ++ t = expand_arith_string (exp, 0); + this_command_name = (char *)NULL; + val = evalexp (t, &expok); free (t); -- return var; -+ return (var == 0 || invisible_p (var)) ? (SHELL_VAR *)0 : var; - } - - /* Return a string containing the elements in the array and subscript -diff -Naur bash-3.0.orig/bashline.c bash-3.0/bashline.c ---- bash-3.0.orig/bashline.c 2004-07-06 03:22:12.000000000 +0000 -+++ bash-3.0/bashline.c 2005-01-08 05:40:42.016724136 +0000 -@@ -100,6 +100,7 @@ - #endif +--- bash-3.1.orig/doc/bash.1 2005-10-12 08:40:52.000000000 -0700 ++++ bash-3.1/doc/bash.1 2006-04-19 15:58:34.000000000 -0700 +@@ -6,12 +6,12 @@ + .\" Case Western Reserve University + .\" chet@po.cwru.edu + .\" +-.\" Last Change: Sat Aug 27 13:28:44 EDT 2005 ++.\" Last Change: Wed Dec 28 19:58:45 EST 2005 + .\" + .\" bash_builtins, strip all but Built-Ins section + .if \n(zZ=1 .ig zZ + .if \n(zY=1 .ig zY +-.TH BASH 1 "2005 Aug 27" "GNU Bash-3.1-beta1" ++.TH BASH 1 "2005 Dec 28" "GNU Bash-3.1" + .\" + .\" There's some problem with having a `@' + .\" in a tagged paragraph with the BSD man macros. +@@ -677,8 +677,8 @@ + .B nocasematch + is enabled, the match is performed without regard to the case + of alphabetic characters. +-The return value is 0 if the string matches or does not match +-the pattern, respectively, and 1 otherwise. ++The return value is 0 if the string matches (\fB==\fP) or does not match ++(\fB!=\fP) the pattern, and 1 otherwise. + Any part of the pattern may be quoted to force it to be matched as a + string. + .if t .sp 0.5 +@@ -807,6 +807,12 @@ + as for pathname expansion (see + .B Pathname Expansion + below). ++The \fIword\fP is expanded using tilde ++expansion, parameter and variable expansion, arithmetic substituion, ++command substitution, process substitution and quote removal. ++Each \fIpattern\fP examined is expanded using tilde ++expansion, parameter and variable expansion, arithmetic substituion, ++command substitution, and process substitution. + If the shell option + .B nocasematch + is enabled, the match is performed without regard to the case +@@ -8484,7 +8490,7 @@ + returns true if any of the arguments are found, false if + none are found. + .TP +-\fBulimit\fP [\fB\-SHacdflmnpstuv\fP [\fIlimit\fP]] ++\fBulimit\fP [\fB\-SHacdfilmnpqstuvx\fP [\fIlimit\fP]] + Provides control over the resources available to the shell and to + processes started by it, on systems that allow such control. + The \fB\-H\fP and \fB\-S\fP options specify that the hard or soft limit is +@@ -8523,6 +8529,9 @@ + .B \-f + The maximum size of files created by the shell + .TP ++.B \-i ++The maximum number of pending signals ++.TP + .B \-l + The maximum size that may be locked into memory + .TP +@@ -8536,6 +8545,9 @@ + .B \-p + The pipe size in 512-byte blocks (this may not be set) + .TP ++.B \-q ++The maximum number of bytes in POSIX message queues ++.TP + .B \-s + The maximum stack size + .TP +@@ -8547,6 +8559,9 @@ + .TP + .B \-v + The maximum amount of virtual memory available to the shell ++.TP ++.B \-x ++The maximum number of file locks + .PD + .PP + If +--- bash-3.1.orig/doc/bashref.texi 2005-10-03 12:07:21.000000000 -0700 ++++ bash-3.1/doc/bashref.texi 2006-04-19 15:58:34.000000000 -0700 +@@ -961,8 +961,8 @@ + (see the description of @code{shopt} in @ref{Bash Builtins}) + is enabled, the match is performed without regard to the case + of alphabetic characters. +-The return value is 0 if the string matches or does not match +-the pattern, respectively, and 1 otherwise. ++The return value is 0 if the string matches (@samp{==}) or does not ++match (@samp{!=})the pattern, and 1 otherwise. + Any part of the pattern may be quoted to force it to be matched as a + string. + +@@ -2598,7 +2598,7 @@ + Builtin commands are necessary to implement functionality impossible + or inconvenient to obtain with separate utilities. + +-This section briefly the builtins which Bash inherits from ++This section briefly describes the builtins which Bash inherits from + the Bourne Shell, as well as the builtin commands which are unique + to or have been extended in Bash. + +@@ -3833,7 +3833,7 @@ + @item ulimit + @btindex ulimit + @example +-ulimit [-acdflmnpstuvSH] [@var{limit}] ++ulimit [-acdfilmnpqstuvxSH] [@var{limit}] + @end example + @code{ulimit} provides control over the resources available to processes + started by the shell, on systems that allow such control. If an +@@ -3857,6 +3857,9 @@ + @item -f + The maximum size of files created by the shell. + ++@item -i ++The maximum number of pending signals. ++ + @item -l + The maximum size that may be locked into memory. - /* Helper functions for Readline. */ -+static int bash_directory_expansion __P((char **)); - static int bash_directory_completion_hook __P((char **)); - static int filename_completion_ignore __P((char **)); - static int bash_push_line __P((void)); -@@ -292,7 +293,7 @@ - /* See if we have anything to do. */ - at = strchr (rl_completer_word_break_characters, '@'); - if ((at == 0 && on_or_off == 0) || (at != 0 && on_or_off != 0)) -- return; -+ return old_value; - - /* We have something to do. Do it. */ - nval = (char *)xmalloc (strlen (rl_completer_word_break_characters) + 1 + on_or_off); -@@ -1406,10 +1407,19 @@ - filename. */ - if (*hint_text == '~') - { -- int l, tl, vl; -+ int l, tl, vl, dl; -+ char *rd; - vl = strlen (val); - tl = strlen (hint_text); -+#if 0 - l = vl - hint_len; /* # of chars added */ -+#else -+ rd = savestring (filename_hint); -+ bash_directory_expansion (&rd); -+ dl = strlen (rd); -+ l = vl - dl; /* # of chars added */ -+ free (rd); -+#endif - temp = (char *)xmalloc (l + 2 + tl); - strcpy (temp, hint_text); - strcpy (temp + tl, val + vl - l); -@@ -2187,6 +2197,27 @@ - return 0; - } +@@ -3869,6 +3872,9 @@ + @item -p + The pipe buffer size. -+/* Simulate the expansions that will be performed by -+ rl_filename_completion_function. This must be called with the address of -+ a pointer to malloc'd memory. */ -+static int -+bash_directory_expansion (dirname) -+ char **dirname; -+{ -+ char *d; -+ -+ d = savestring (*dirname); -+ -+ if (rl_directory_rewrite_hook) -+ (*rl_directory_rewrite_hook) (&d); ++@item -q ++The maximum number of bytes in POSIX message queues. + -+ if (rl_directory_completion_hook && (*rl_directory_completion_hook) (&d)) -+ { -+ free (*dirname); -+ *dirname = d; -+ } -+} -+ - /* Handle symbolic link references and other directory name - expansions while hacking completion. */ - static int -@@ -2513,7 +2544,7 @@ - static char **matches = (char **)NULL; - static int ind; - int glen; -- char *ret; -+ char *ret, *ttext; - - if (state == 0) - { -@@ -2523,17 +2554,22 @@ - FREE (globorig); - FREE (globtext); + @item -s + The maximum stack size. -+ ttext = bash_tilde_expand (text, 0); +@@ -3881,6 +3887,9 @@ + @item -v + The maximum amount of virtual memory available to the process. + ++@item -x ++The maximum number of file locks. + - if (rl_explicit_arg) - { -- globorig = savestring (text); -- glen = strlen (text); -+ globorig = savestring (ttext); -+ glen = strlen (ttext); - globtext = (char *)xmalloc (glen + 2); -- strcpy (globtext, text); -+ strcpy (globtext, ttext); - globtext[glen] = '*'; - globtext[glen+1] = '\0'; + @end table + + If @var{limit} is given, it is the new value of the specified resource; +@@ -4089,8 +4098,8 @@ + Print shell input lines as they are read. + + @item -x +-Print a trace of simple commands, \fBfor\fP commands, \fBcase\fP +-commands, \fBselect\fP commands, and arithmetic \fBfor\fP commands ++Print a trace of simple commands, @code{for} commands, @code{case} ++commands, @code{select} commands, and arithmetic @code{for} commands + and their arguments or associated word lists after they are + expanded and before they are executed. The value of the @env{PS4} + variable is expanded and the resultant value is printed before +--- bash-3.1.orig/doc/version.texi 2005-09-20 11:52:56.000000000 -0700 ++++ bash-3.1/doc/version.texi 2006-04-19 15:58:34.000000000 -0700 +@@ -2,9 +2,9 @@ + Copyright (C) 1988-2005 Free Software Foundation, Inc. + @end ignore + +-@set LASTCHANGE Mon Sep 5 11:47:04 EDT 2005 ++@set LASTCHANGE Fri Dec 30 10:50:51 EST 2005 + +-@set EDITION 3.1-beta1 +-@set VERSION 3.1-beta1 +-@set UPDATED 5 September 2005 +-@set UPDATED-MONTH September 2005 ++@set EDITION 3.1 ++@set VERSION 3.1 ++@set UPDATED 30 December 2005 ++@set UPDATED-MONTH December 2005 +--- bash-3.1.orig/jobs.c 2005-11-11 20:13:27.000000000 -0800 ++++ bash-3.1/jobs.c 2006-04-19 15:58:34.000000000 -0700 +@@ -619,8 +619,11 @@ + * once in the parent and once in each child. This is where + * the parent gives it away. + * ++ * Don't give the terminal away if this shell is an asynchronous ++ * subshell. ++ * + */ +- if (job_control && newjob->pgrp) ++ if (job_control && newjob->pgrp && (subshell_environment&SUBSHELL_ASYNC) == 0) + give_terminal_to (newjob->pgrp, 0); } - else -- globtext = globorig = savestring (text); -+ globtext = globorig = savestring (ttext); -+ -+ if (ttext != text) -+ free (ttext); - - matches = shell_glob_filename (globtext); - if (GLOB_FAILED (matches)) -diff -Naur bash-3.0.orig/braces.c bash-3.0/braces.c ---- bash-3.0.orig/braces.c 2003-12-04 16:09:52.000000000 +0000 -+++ bash-3.0/braces.c 2005-01-08 05:40:50.317462232 +0000 -@@ -340,8 +340,8 @@ - - if (lhs_t == ST_CHAR) - { -- lhs_v = lhs[0]; -- rhs_v = rhs[0]; -+ lhs_v = (unsigned char)lhs[0]; -+ rhs_v = (unsigned char)rhs[0]; } - else - { -@@ -402,6 +402,8 @@ - { - pass_next = 1; - i++; -+ if (quoted == 0) -+ level++; - continue; - } - #endif -diff -Naur bash-3.0.orig/builtins/trap.def bash-3.0/builtins/trap.def ---- bash-3.0.orig/builtins/trap.def 2004-05-28 02:26:19.000000000 +0000 -+++ bash-3.0/builtins/trap.def 2005-01-08 05:40:04.443436144 +0000 -@@ -23,7 +23,7 @@ - - $BUILTIN trap - $FUNCTION trap_builtin --$SHORT_DOC trap [-lp] [[arg] signal_spec ...] -+$SHORT_DOC trap [-lp] [arg signal_spec ...] - The command ARG is to be read and executed when the shell receives - signal(s) SIGNAL_SPEC. If ARG is absent (and a single SIGNAL_SPEC - is supplied) or `-', each specified signal is reset to its original -@@ -87,7 +87,7 @@ - trap_builtin (list) - WORD_LIST *list; +@@ -844,9 +847,10 @@ + realloc_jobs_list () { -- int list_signal_names, display, result, opt; -+ int list_signal_names, display, result, opt, first_signal; - - list_signal_names = display = 0; - result = EXECUTION_SUCCESS; -@@ -118,14 +118,19 @@ - else - { - char *first_arg; -- int operation, sig; -+ int operation, sig, first_signal; - - operation = SET; - first_arg = list->word->word; -+ first_signal = first_arg && *first_arg && all_digits (first_arg) && signal_object_p (first_arg, opt); + sigset_t set, oset; +- int nsize, i, j; ++ int nsize, i, j, ncur, nprev; + JOB **nlist; + ++ ncur = nprev = NO_JOB; + nsize = ((js.j_njobs + JOB_SLOTS - 1) / JOB_SLOTS); + nsize *= JOB_SLOTS; + i = js.j_njobs % JOB_SLOTS; +@@ -854,17 +858,51 @@ + nsize += JOB_SLOTS; + + BLOCK_CHILD (set, oset); +- nlist = (JOB **) xmalloc (nsize * sizeof (JOB *)); ++ nlist = (js.j_jobslots == nsize) ? jobs : (JOB **) xmalloc (nsize * sizeof (JOB *)); + -+ /* Backwards compatibility */ -+ if (first_signal) -+ operation = REVERT; - /* When in posix mode, the historical behavior of looking for a - missing first argument is disabled. To revert to the original - signal handling disposition, use `-' as the first argument. */ -- if (posixly_correct == 0 && first_arg && *first_arg && -+ else if (posixly_correct == 0 && first_arg && *first_arg && - (*first_arg != '-' || first_arg[1]) && - signal_object_p (first_arg, opt) && list->next == 0) - operation = REVERT; -diff -Naur bash-3.0.orig/doc/bashref.texi bash-3.0/doc/bashref.texi ---- bash-3.0.orig/doc/bashref.texi 2004-06-26 18:26:07.000000000 +0000 -+++ bash-3.0/doc/bashref.texi 2005-01-08 05:40:04.494428392 +0000 -@@ -5953,7 +5953,8 @@ - @item - The @code{trap} builtin doesn't check the first argument for a possible - signal specification and revert the signal handling to the original --disposition if it is. If users want to reset the handler for a given -+disposition if it is, unless that argument consists solely of digits and -+is a valid signal number. If users want to reset the handler for a given - signal to the original disposition, they should use @samp{-} as the - first argument. - -diff -Naur bash-3.0.orig/general.c bash-3.0/general.c ---- bash-3.0.orig/general.c 2004-04-15 03:20:13.000000000 +0000 -+++ bash-3.0/general.c 2005-01-08 05:40:51.913219640 +0000 -@@ -267,7 +267,7 @@ - c = string[indx = 0]; - - #if defined (ARRAY_VARS) -- if ((legal_variable_starter (c) == 0) && (flags && c != '[')) /* ] */ -+ if ((legal_variable_starter (c) == 0) && (flags == 0 || c != '[')) /* ] */ - #else - if (legal_variable_starter (c) == 0) - #endif -diff -Naur bash-3.0.orig/include/shmbutil.h bash-3.0/include/shmbutil.h ---- bash-3.0.orig/include/shmbutil.h 2004-04-19 13:59:42.000000000 +0000 -+++ bash-3.0/include/shmbutil.h 2005-01-08 05:40:05.724241432 +0000 -@@ -31,6 +31,8 @@ - extern size_t xmbsrtowcs __P((wchar_t *, const char **, size_t, mbstate_t *)); - extern size_t xdupmbstowcs __P((wchar_t **, char ***, const char *)); - -+extern size_t mbstrlen __P((const char *)); + for (i = j = 0; i < js.j_jobslots; i++) + if (jobs[i]) +- nlist[j++] = jobs[i]; ++ { ++ if (i == js.j_current) ++ ncur = j; ++ if (i == js.j_previous) ++ nprev = j; ++ nlist[j++] = jobs[i]; ++ } + - extern char *xstrchr __P((const char *, int)); - - #ifndef MB_INVALIDCH -@@ -38,6 +40,9 @@ - #define MB_NULLWCH(x) ((x) == 0) - #endif ++#if defined (DEBUG) ++ itrace ("realloc_jobs_list: resize jobs list from %d to %d", js.j_jobslots, nsize); ++ itrace ("realloc_jobs_list: j_lastj changed from %d to %d", js.j_lastj, (j > 0) ? j - 1 : 0); ++ itrace ("realloc_jobs_list: j_njobs changed from %d to %d", js.j_njobs, (j > 0) ? j - 1 : 0); ++#endif -+#define MBSLEN(s) (((s) && (s)[0]) ? ((s)[1] ? mbstrlen (s) : 1) : 0) -+#define MB_STRLEN(s) ((MB_CUR_MAX > 1) ? MBSLEN (s) : STRLEN (s)) + js.j_firstj = 0; +- js.j_lastj = (j > 0) ? j - 1: 0; ++ js.j_lastj = (j > 0) ? j - 1 : 0; ++ js.j_njobs = j; + js.j_jobslots = nsize; + +- free (jobs); +- jobs = nlist; ++ /* Zero out remaining slots in new jobs list */ ++ for ( ; j < nsize; j++) ++ nlist[j] = (JOB *)NULL; ++ ++ if (jobs != nlist) ++ { ++ free (jobs); ++ jobs = nlist; ++ } ++ ++ if (ncur != NO_JOB) ++ js.j_current = ncur; ++ if (nprev != NO_JOB) ++ js.j_previous = nprev; + - #else /* !HANDLE_MULTIBYTE */ ++ /* Need to reset these */ ++ if (js.j_current == NO_JOB || js.j_previous == NO_JOB || js.j_current > js.j_lastj || js.j_previous > js.j_lastj) ++ reset_current (); ++ ++#ifdef DEBUG ++ itrace ("realloc_jobs_list: reset js.j_current (%d) and js.j_previous (%d)", js.j_current, js.j_previous); ++#endif - #undef MB_LEN_MAX -@@ -54,6 +59,8 @@ - #define MB_NULLWCH(x) (0) - #endif + UNBLOCK_CHILD (oset); + } +@@ -1655,7 +1693,7 @@ + In this case, we don't want to give the terminal to the + shell's process group (we could be in the middle of a + pipeline, for example). */ +- if (async_p == 0 && pipeline_pgrp != shell_pgrp) ++ if (async_p == 0 && pipeline_pgrp != shell_pgrp && ((subshell_environment&SUBSHELL_ASYNC) == 0)) + give_terminal_to (pipeline_pgrp, 0); + + #if defined (PGRP_PIPE) +@@ -2198,7 +2236,11 @@ + /* This is possibly a race condition -- should it go in stop_pipeline? */ + wait_sigint_received = 0; + if (job_control == 0) +- old_sigint_handler = set_signal_handler (SIGINT, wait_sigint_handler); ++ { ++ old_sigint_handler = set_signal_handler (SIGINT, wait_sigint_handler); ++ if (old_sigint_handler == SIG_IGN) ++ set_signal_handler (SIGINT, old_sigint_handler); ++ } -+#define MB_STRLEN(s) (STRLEN(s)) -+ - #endif /* !HANDLE_MULTIBYTE */ - - /* Declare and initialize a multibyte state. Call must be terminated -diff -Naur bash-3.0.orig/jobs.c bash-3.0/jobs.c ---- bash-3.0.orig/jobs.c 2004-04-23 20:28:25.000000000 +0000 -+++ bash-3.0/jobs.c 2005-01-08 05:40:40.567944384 +0000 -@@ -1778,8 +1778,13 @@ - if (pipefail_opt) - { - fail = 0; -- for (p = jobs[job]->pipe; p->next != jobs[job]->pipe; p = p->next) -- if (p->status != EXECUTION_SUCCESS) fail = p->status; -+ p = jobs[job]->pipe; -+ do -+ { -+ if (p->status != EXECUTION_SUCCESS) fail = p->status; -+ p = p->next; -+ } -+ while (p != jobs[job]->pipe); - return fail; - } + termination_state = last_command_exit_value; -diff -Naur bash-3.0.orig/lib/readline/display.c bash-3.0/lib/readline/display.c ---- bash-3.0.orig/lib/readline/display.c 2004-05-28 02:57:51.000000000 +0000 -+++ bash-3.0/lib/readline/display.c 2005-01-08 05:40:08.574808080 +0000 -@@ -201,7 +201,7 @@ - int *lp, *lip, *niflp, *vlp; - { - char *r, *ret, *p; -- int l, rl, last, ignoring, ninvis, invfl, ind, pind, physchars; -+ int l, rl, last, ignoring, ninvis, invfl, invflset, ind, pind, physchars; +--- bash-3.1.orig/lib/glob/glob.c 2005-03-24 09:42:27.000000000 -0800 ++++ bash-3.1/lib/glob/glob.c 2006-04-19 15:58:34.000000000 -0700 +@@ -360,6 +360,7 @@ + count = lose = skip = 0; - /* Short-circuit if we can. */ - if ((MB_CUR_MAX <= 1 || rl_byte_oriented) && strchr (pmt, RL_PROMPT_START_IGNORE) == 0) -@@ -222,6 +222,7 @@ - r = ret = (char *)xmalloc (l + 1); + firstmalloc = 0; ++ nalloca = 0; - invfl = 0; /* invisible chars in first line of prompt */ -+ invflset = 0; /* we only want to set invfl once */ + /* If PAT is empty, skip the loop, but return one (empty) filename. */ + if (pat == 0 || *pat == '\0') +@@ -546,6 +547,8 @@ + firstmalloc = 0; + tmplink = lastlink; + } ++ else ++ tmplink = 0; + free (lastlink->name); + lastlink = lastlink->next; + FREE (tmplink); +--- bash-3.1.orig/lib/glob/sm_loop.c 2005-10-16 18:21:04.000000000 -0700 ++++ bash-3.1/lib/glob/sm_loop.c 2006-04-19 15:58:34.000000000 -0700 +@@ -638,12 +638,13 @@ + CHAR *psub; /* pointer to sub-pattern */ + CHAR *pnext; /* pointer to next sub-pattern */ + CHAR *srest; /* pointer to rest of string */ +- int m1, m2; ++ int m1, m2, xflags; /* xflags = flags passed to recursive matches */ + + #if DEBUG_MATCHING + fprintf(stderr, "extmatch: xc = %c\n", xc); + fprintf(stderr, "extmatch: s = %s; se = %s\n", s, se); + fprintf(stderr, "extmatch: p = %s; pe = %s\n", p, pe); ++fprintf(stderr, "extmatch: flags = %d\n", flags); + #endif - for (rl = ignoring = last = ninvis = physchars = 0, p = pmt; p && *p; p++) - { -@@ -249,7 +250,10 @@ - while (l--) - *r++ = *p++; - if (!ignoring) -- rl += ind - pind; + prest = PATSCAN (p + (*p == L('(')), pe, 0); /* ) */ +@@ -677,8 +678,12 @@ + string matches the rest of the pattern. Also handle + multiple matches of the pattern. */ + if (m1) +- m2 = (GMATCH (srest, se, prest, pe, flags) == 0) || +- (s != srest && GMATCH (srest, se, p - 1, pe, flags) == 0); + { -+ rl += ind - pind; -+ physchars += _rl_col_width (pmt, pind, ind); ++ /* if srest > s, we are not at start of string */ ++ xflags = (srest > s) ? (flags & ~FNM_PERIOD) : flags; ++ m2 = (GMATCH (srest, se, prest, pe, xflags) == 0) || ++ (s != srest && GMATCH (srest, se, p - 1, pe, xflags) == 0); + } - else - ninvis += ind - pind; - p--; /* compensate for later increment */ -@@ -259,16 +263,19 @@ + if (m1 && m2) + return (0); + } +@@ -704,8 +709,10 @@ + srest = (prest == pe) ? se : s; + for ( ; srest <= se; srest++) { - *r++ = *p; - if (!ignoring) -- rl++; /* visible length byte counter */ -+ { -+ rl++; /* visible length byte counter */ -+ physchars++; -+ } - else - ninvis++; /* invisible chars byte counter */ ++ /* if srest > s, we are not at start of string */ ++ xflags = (srest > s) ? (flags & ~FNM_PERIOD) : flags; + if (GMATCH (s, srest, psub, pnext - 1, flags) == 0 && +- GMATCH (srest, se, prest, pe, flags) == 0) ++ GMATCH (srest, se, prest, pe, xflags) == 0) + return (0); } - -- if (rl >= _rl_screenwidth) -- invfl = ninvis; -- -- if (ignoring == 0) -- physchars++; -+ if (invflset == 0 && rl >= _rl_screenwidth) -+ { -+ invfl = ninvis; -+ invflset = 1; -+ } + if (pnext == prest) +@@ -726,7 +733,9 @@ + if (pnext == prest) + break; + } +- if (m1 == 0 && GMATCH (srest, se, prest, pe, flags) == 0) ++ /* if srest > s, we are not at start of string */ ++ xflags = (srest > s) ? (flags & ~FNM_PERIOD) : flags; ++ if (m1 == 0 && GMATCH (srest, se, prest, pe, xflags) == 0) + return (0); } + return (FNM_NOMATCH); +--- bash-3.1.orig/lib/readline/display.c 2005-11-30 11:05:02.000000000 -0800 ++++ bash-3.1/lib/readline/display.c 2006-04-19 15:58:34.000000000 -0700 +@@ -1983,11 +1983,15 @@ + int pchar; + { + int len; +- char *pmt; ++ char *pmt, *p; + + rl_save_prompt (); + +- if (saved_local_prompt == 0) ++ /* We've saved the prompt, and can do anything with the various prompt ++ strings we need before they're restored. We want the unexpanded ++ portion of the prompt string after any final newline. */ ++ p = rl_prompt ? strrchr (rl_prompt, '\n') : 0; ++ if (p == 0) + { + len = (rl_prompt && *rl_prompt) ? strlen (rl_prompt) : 0; + pmt = (char *)xmalloc (len + 2); +@@ -1998,19 +2002,17 @@ } + else + { +- len = *saved_local_prompt ? strlen (saved_local_prompt) : 0; ++ p++; ++ len = strlen (p); + pmt = (char *)xmalloc (len + 2); + if (len) +- strcpy (pmt, saved_local_prompt); ++ strcpy (pmt, p); + pmt[len] = pchar; + pmt[len+1] = '\0'; +- local_prompt = savestring (pmt); +- prompt_last_invisible = saved_last_invisible; +- prompt_visible_length = saved_visible_length + 1; +- } ++ } -@@ -351,14 +358,14 @@ - local_prompt = expand_prompt (p, &prompt_visible_length, - &prompt_last_invisible, - (int *)NULL, -- (int *)NULL); -+ &prompt_physical_chars); - c = *t; *t = '\0'; - /* The portion of the prompt string up to and including the - final newline is now null-terminated. */ - local_prompt_prefix = expand_prompt (prompt, &prompt_prefix_length, - (int *)NULL, - &prompt_invis_chars_first_line, -- &prompt_physical_chars); -+ (int *)NULL); - *t = c; - return (prompt_prefix_length); - } -@@ -417,7 +424,7 @@ - register int in, out, c, linenum, cursor_linenum; - register char *line; - int c_pos, inv_botlin, lb_botlin, lb_linenum; -- int newlines, lpos, temp, modmark; -+ int newlines, lpos, temp, modmark, n0, num; - char *prompt_this_line; - #if defined (HANDLE_MULTIBYTE) - wchar_t wc; -@@ -573,6 +580,7 @@ - - #if defined (HANDLE_MULTIBYTE) - memset (_rl_wrapped_line, 0, vis_lbsize); -+ num = 0; - #endif ++ /* will be overwritten by expand_prompt, called from rl_message */ + prompt_physical_chars = saved_physical_chars + 1; +- + return pmt; + } + +--- bash-3.1.orig/lib/readline/readline.c 2005-07-04 19:29:35.000000000 -0700 ++++ bash-3.1/lib/readline/readline.c 2006-04-19 15:58:34.000000000 -0700 +@@ -282,6 +282,7 @@ + { + FREE (rl_prompt); + rl_prompt = prompt ? savestring (prompt) : (char *)NULL; ++ rl_display_prompt = rl_prompt ? rl_prompt : ""; - /* prompt_invis_chars_first_line is the number of invisible characters in -@@ -591,13 +599,32 @@ - probably too much work for the benefit gained. How many people have - prompts that exceed two physical lines? - Additional logic fix from Edward Catmur */ -+#if defined (HANDLE_MULTIBYTE) -+ n0 = num; -+ temp = local_prompt ? strlen (local_prompt) : 0; -+ while (num < temp) + rl_visible_prompt_length = rl_expand_prompt (rl_prompt); + return 0; +--- bash-3.1.orig/lib/readline/terminal.c 2005-11-12 17:46:54.000000000 -0800 ++++ bash-3.1/lib/readline/terminal.c 2006-04-19 15:58:34.000000000 -0700 +@@ -122,7 +122,7 @@ + static char *_rl_visible_bell; + + /* Non-zero means the terminal can auto-wrap lines. */ +-int _rl_term_autowrap; ++int _rl_term_autowrap = -1; + + /* Non-zero means that this terminal has a meta key. */ + static int term_has_meta; +@@ -274,6 +274,9 @@ + _rl_set_screen_size (rows, cols) + int rows, cols; + { ++ if (_rl_term_autowrap == -1) ++ _rl_init_terminal_io (rl_terminal_name); ++ + if (rows > 0) + _rl_screenheight = rows; + if (cols > 0) +--- bash-3.1.orig/parse.y 2005-11-11 20:14:18.000000000 -0800 ++++ bash-3.1/parse.y 2006-04-19 15:58:34.000000000 -0700 +@@ -2716,6 +2716,7 @@ + #define P_ALLOWESC 0x02 + #define P_DQUOTE 0x04 + #define P_COMMAND 0x08 /* parsing a command, so look for comments */ ++#define P_BACKQUOTE 0x10 /* parsing a backquoted command substitution */ + + static char matched_pair_error; + static char * +@@ -2725,12 +2726,12 @@ + int *lenp, flags; + { + int count, ch, was_dollar, in_comment, check_comment; +- int pass_next_character, nestlen, ttranslen, start_lineno; ++ int pass_next_character, backq_backslash, nestlen, ttranslen, start_lineno; + char *ret, *nestret, *ttrans; + int retind, retsize, rflags; + + count = 1; +- pass_next_character = was_dollar = in_comment = 0; ++ pass_next_character = backq_backslash = was_dollar = in_comment = 0; + check_comment = (flags & P_COMMAND) && qc != '\'' && qc != '"' && (flags & P_DQUOTE) == 0; + + /* RFLAGS is the set of flags we want to pass to recursive calls. */ +@@ -2742,11 +2743,8 @@ + start_lineno = line_number; + while (count) + { +-#if 0 +- ch = shell_getc ((qc != '\'' || (flags & P_ALLOWESC)) && pass_next_character == 0); +-#else +- ch = shell_getc (qc != '\'' && pass_next_character == 0); +-#endif ++ ch = shell_getc (qc != '\'' && pass_next_character == 0 && backq_backslash == 0); ++ + if (ch == EOF) + { + free (ret); +@@ -2771,9 +2769,16 @@ + continue; + } + /* Not exactly right yet */ +- else if (check_comment && in_comment == 0 && ch == '#' && (retind == 0 || ret[retind-1] == '\n' || whitespace (ret[retind -1]))) ++ else if MBTEST(check_comment && in_comment == 0 && ch == '#' && (retind == 0 || ret[retind-1] == '\n' || whitespace (ret[retind - 1]))) + in_comment = 1; + ++ /* last char was backslash inside backquoted command substitution */ ++ if (backq_backslash) + { -+ if (_rl_col_width (local_prompt, n0, num) > _rl_screenwidth) -+ { -+ num = _rl_find_prev_mbchar (local_prompt, num, MB_FIND_ANY); -+ break; -+ } -+ num++; ++ backq_backslash = 0; ++ /* Placeholder for adding special characters */ + } -+ temp = num + -+#else - temp = ((newlines + 1) * _rl_screenwidth) + -+#endif /* !HANDLE_MULTIBYTE */ - ((local_prompt_prefix == 0) ? ((newlines == 0) ? prompt_invis_chars_first_line - : ((newlines == 1) ? wrap_offset : 0)) - : ((newlines == 0) ? wrap_offset :0)); - - inv_lbreaks[++newlines] = temp; -+#if defined (HANDLE_MULTIBYTE) -+ lpos -= _rl_col_width (local_prompt, n0, num); -+#else - lpos -= _rl_screenwidth; -+#endif - } ++ + if (pass_next_character) /* last char was backslash */ + { + pass_next_character = 0; +@@ -2814,6 +2819,8 @@ + { + if MBTEST((flags & P_ALLOWESC) && ch == '\\') + pass_next_character++; ++ else if MBTEST((flags & P_BACKQUOTE) && ch == '\\') ++ backq_backslash++; + continue; + } - prompt_last_screen_line = newlines; -diff -Naur bash-3.0.orig/lib/readline/mbutil.c bash-3.0/lib/readline/mbutil.c ---- bash-3.0.orig/lib/readline/mbutil.c 2004-01-14 14:44:52.000000000 +0000 -+++ bash-3.0/lib/readline/mbutil.c 2005-01-08 05:40:39.252144416 +0000 -@@ -126,11 +126,11 @@ - if (find_non_zero) - { - tmp = mbrtowc (&wc, string + point, strlen (string + point), &ps); -- while (wcwidth (wc) == 0) -+ while (tmp > 0 && wcwidth (wc) == 0) +@@ -2898,7 +2905,11 @@ + } + else if MBTEST(qc == '`' && (ch == '"' || ch == '\'') && in_comment == 0) { - point += tmp; - tmp = mbrtowc (&wc, string + point, strlen (string + point), &ps); -- if (tmp == (size_t)(0) || tmp == (size_t)(-1) || tmp == (size_t)(-2)) -+ if (MB_NULLWCH (tmp) || MB_INVALIDCH (tmp)) - break; +- nestret = parse_matched_pair (0, ch, ch, &nestlen, rflags); ++ /* Add P_BACKQUOTE so backslash quotes the next character and ++ shell_getc does the right thing with \. We do this for ++ a measure of backwards compatibility -- it's not strictly the ++ right POSIX thing. */ ++ nestret = parse_matched_pair (0, ch, ch, &nestlen, rflags|P_BACKQUOTE); + goto add_nestret; } + else if MBTEST(was_dollar && (ch == '(' || ch == '{' || ch == '[')) /* ) } ] */ +@@ -2907,7 +2918,7 @@ + if (open == ch) /* undo previous increment */ + count--; + if (ch == '(') /* ) */ +- nestret = parse_matched_pair (0, '(', ')', &nestlen, rflags); ++ nestret = parse_matched_pair (0, '(', ')', &nestlen, rflags & ~P_DQUOTE); + else if (ch == '{') /* } */ + nestret = parse_matched_pair (0, '{', '}', &nestlen, P_FIRSTCLOSE|rflags); + else if (ch == '[') /* ] */ +@@ -3578,7 +3589,7 @@ + FREE (ttok); + all_digit_token = 0; + compound_assignment = 1; +-#if 0 ++#if 1 + goto next_character; + #else + goto got_token; /* ksh93 seems to do this */ +@@ -3695,7 +3706,9 @@ + struct builtin *b; + b = builtin_address_internal (token, 0); + if (b && (b->flags & ASSIGNMENT_BUILTIN)) +- parser_state |= PST_ASSIGNOK; ++ parser_state |= PST_ASSIGNOK; ++ else if (STREQ (token, "eval") || STREQ (token, "let")) ++ parser_state |= PST_ASSIGNOK; } -diff -Naur bash-3.0.orig/lib/readline/misc.c bash-3.0/lib/readline/misc.c ---- bash-3.0.orig/lib/readline/misc.c 2004-07-07 12:56:32.000000000 +0000 -+++ bash-3.0/lib/readline/misc.c 2005-01-08 05:40:07.040041400 +0000 -@@ -276,12 +276,6 @@ - _rl_saved_line_for_history->line = savestring (rl_line_buffer); - _rl_saved_line_for_history->data = (char *)rl_undo_list; + + yylval.word = the_word; +@@ -4686,18 +4699,21 @@ + int *retlenp; + { + WORD_LIST *wl, *rl; +- int tok, orig_line_number, orig_token_size; ++ int tok, orig_line_number, orig_token_size, orig_last_token, assignok; + char *saved_token, *ret; + + saved_token = token; + orig_token_size = token_buffer_size; + orig_line_number = line_number; ++ orig_last_token = last_read_token; + + last_read_token = WORD; /* WORD to allow reserved words here */ + + token = (char *)NULL; + token_buffer_size = 0; + ++ assignok = parser_state&PST_ASSIGNOK; /* XXX */ ++ + wl = (WORD_LIST *)NULL; /* ( */ + parser_state |= PST_COMPASSIGN; + +@@ -4740,7 +4756,7 @@ + jump_to_top_level (DISCARD); } -- else if (STREQ (rl_line_buffer, _rl_saved_line_for_history->line) == 0) -- { -- free (_rl_saved_line_for_history->line); -- _rl_saved_line_for_history->line = savestring (rl_line_buffer); -- _rl_saved_line_for_history->data = (char *)rl_undo_list; /* XXX possible memleak */ -- } - return 0; - } -diff -Naur bash-3.0.orig/lib/readline/vi_mode.c bash-3.0/lib/readline/vi_mode.c ---- bash-3.0.orig/lib/readline/vi_mode.c 2004-07-13 18:08:27.000000000 +0000 -+++ bash-3.0/lib/readline/vi_mode.c 2005-01-08 05:40:25.349257976 +0000 -@@ -272,10 +272,12 @@ - switch (key) +- last_read_token = WORD; ++ last_read_token = orig_last_token; /* XXX - was WORD? */ + if (wl) { - case '?': -+ _rl_free_saved_history_line (); - rl_noninc_forward_search (count, key); - break; + rl = REVERSE_LIST (wl, WORD_LIST *); +@@ -4752,6 +4768,10 @@ - case '/': -+ _rl_free_saved_history_line (); - rl_noninc_reverse_search (count, key); - break; + if (retlenp) + *retlenp = (ret && *ret) ? strlen (ret) : 0; ++ ++ if (assignok) ++ parser_state |= PST_ASSIGNOK; ++ + return ret; + } -@@ -690,7 +692,7 @@ - { - wchar_t wc; - char mb[MB_LEN_MAX+1]; -- int mblen; -+ int mblen, p; - mbstate_t ps; - - memset (&ps, 0, sizeof (mbstate_t)); -@@ -713,11 +715,14 @@ - /* Vi is kind of strange here. */ - if (wc) - { -+ p = rl_point; - mblen = wcrtomb (mb, wc, &ps); - if (mblen >= 0) - mb[mblen] = '\0'; - rl_begin_undo_group (); -- rl_delete (1, 0); -+ rl_vi_delete (1, 0); -+ if (rl_point < p) /* Did we retreat at EOL? */ -+ rl_point++; /* XXX - should we advance more than 1 for mbchar? */ - rl_insert_text (mb); - rl_end_undo_group (); - rl_vi_check (); -@@ -1310,12 +1315,16 @@ - rl_vi_delete (1, c); - #if defined (HANDLE_MULTIBYTE) - if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) -- while (_rl_insert_char (1, c)) -- { -- RL_SETSTATE (RL_STATE_MOREINPUT); -- c = rl_read_key (); -- RL_UNSETSTATE (RL_STATE_MOREINPUT); -- } -+ { -+ if (rl_point < p) /* Did we retreat at EOL? */ -+ rl_point++; -+ while (_rl_insert_char (1, c)) -+ { -+ RL_SETSTATE (RL_STATE_MOREINPUT); -+ c = rl_read_key (); -+ RL_UNSETSTATE (RL_STATE_MOREINPUT); -+ } -+ } - else - #endif - { -diff -Naur bash-3.0.orig/patchlevel.h bash-3.0/patchlevel.h ---- bash-3.0.orig/patchlevel.h 2001-08-22 12:05:39.000000000 +0000 -+++ bash-3.0/patchlevel.h 2005-01-08 05:40:53.584965496 +0000 +--- bash-3.1.orig/patchlevel.h 2005-07-20 10:58:20.000000000 -0700 ++++ bash-3.1/patchlevel.h 2006-04-19 15:59:29.000000000 -0700 @@ -25,6 +25,6 @@ regexp `^#define[ ]*PATCHLEVEL', since that's what support/mkversion.sh looks for to find the patch level (for the sccs version string). */ -#define PATCHLEVEL 0 -+#define PATCHLEVEL 16 ++#define PATCHLEVEL 17 #endif /* _PATCHLEVEL_H_ */ -diff -Naur bash-3.0.orig/pcomplete.c bash-3.0/pcomplete.c ---- bash-3.0.orig/pcomplete.c 2004-01-08 15:36:17.000000000 +0000 -+++ bash-3.0/pcomplete.c 2005-01-08 05:40:02.049800032 +0000 -@@ -863,6 +863,8 @@ - if (array_p (v) == 0) - v = convert_var_to_array (v); - v = assign_array_var_from_word_list (v, lwords); -+ -+ VUNSETATTR (v, att_invisible); - return v; - } - #endif /* ARRAY_VARS */ -@@ -1022,6 +1024,8 @@ - if (array_p (v) == 0) - v = convert_var_to_array (v); - -+ VUNSETATTR (v, att_invisible); -+ - a = array_cell (v); - if (a == 0 || array_empty (a)) - sl = (STRINGLIST *)NULL; -diff -Naur bash-3.0.orig/subst.c bash-3.0/subst.c ---- bash-3.0.orig/subst.c 2004-07-04 17:56:13.000000000 +0000 -+++ bash-3.0/subst.c 2005-01-08 05:40:53.574967016 +0000 -@@ -4691,6 +4691,26 @@ - legal_identifier (name + 1)); /* ${#PS1} */ +--- bash-3.1.orig/subst.c 2005-10-24 06:51:13.000000000 -0700 ++++ bash-3.1/subst.c 2006-04-19 15:59:29.000000000 -0700 +@@ -2187,7 +2187,7 @@ + if (mklocal && variable_context) + { + v = find_variable (name); +- if (v == 0 || array_p (v) == 0) ++ if (v == 0 || array_p (v) == 0 || v->context != variable_context) + v = make_local_array_variable (name); + v = assign_array_var_from_string (v, value, flags); + } +@@ -2575,6 +2575,13 @@ + return (expand_string_to_string_internal (string, quoted, expand_string_assignment)); } -+#if defined (HANDLE_MULTIBYTE) -+size_t -+mbstrlen (s) -+ const char *s; ++char * ++expand_arith_string (string, quoted) ++ char *string; +{ -+ size_t clen, nc; -+ mbstate_t mbs; -+ -+ nc = 0; -+ memset (&mbs, 0, sizeof (mbs)); -+ while ((clen = mbrlen(s, MB_CUR_MAX, &mbs)) != 0 && (MB_INVALIDCH(clen) == 0)) -+ { -+ s += clen; -+ nc++; -+ } -+ return nc; ++ return (expand_string_if_necessary (string, quoted, expand_string)); +} -+#endif -+ + - /* Handle the parameter brace expansion that requires us to return the - length of a parameter. */ - static intmax_t -@@ -4746,14 +4766,14 @@ - if (legal_number (name + 1, &arg_index)) /* ${#1} */ - { - t = get_dollar_var_value (arg_index); -- number = STRLEN (t); -+ number = MB_STRLEN (t); - FREE (t); - } - #if defined (ARRAY_VARS) -- else if ((var = find_variable (name + 1)) && array_p (var)) -+ else if ((var = find_variable (name + 1)) && (invisible_p (var) == 0) && array_p (var)) - { - t = array_reference (array_cell (var), 0); -- number = STRLEN (t); -+ number = MB_STRLEN (t); - } - #endif - else /* ${#PS1} */ -@@ -4766,7 +4786,7 @@ - if (list) - dispose_words (list); - -- number = STRLEN (t); -+ number = MB_STRLEN (t); - FREE (t); - } - } -@@ -4871,7 +4891,7 @@ - { - case VT_VARIABLE: - case VT_ARRAYMEMBER: -- len = strlen (value); -+ len = MB_STRLEN (value); - break; - case VT_POSPARMS: - len = number_of_args () + 1; -@@ -4879,8 +4899,9 @@ - #if defined (ARRAY_VARS) - case VT_ARRAYVAR: - a = (ARRAY *)value; -- /* For arrays, the first value deals with array indices. */ -- len = array_max_index (a); /* arrays index from 0 to n - 1 */ -+ /* For arrays, the first value deals with array indices. Negative -+ offsets count from one past the array's maximum index. */ -+ len = array_max_index (a) + (*e1p < 0); /* arrays index from 0 to n - 1 */ - break; - #endif - } -@@ -4891,7 +4912,7 @@ - if (*e1p < 0) /* negative offsets count from end */ - *e1p += len; - -- if (*e1p >= len || *e1p < 0) -+ if (*e1p > len || *e1p < 0) - return (-1); - - #if defined (ARRAY_VARS) -@@ -4982,7 +5003,7 @@ - else - return -1; - } -- else if ((v = find_variable (varname)) && array_p (v)) -+ else if ((v = find_variable (varname)) && (invisible_p (v) == 0) && array_p (v)) + #if defined (COND_COMMAND) + /* Just remove backslashes in STRING. Returns a new string. */ + char * +@@ -5248,7 +5255,7 @@ + else + t = (char *)0; + +- temp1 = expand_string_if_necessary (substr, Q_DOUBLE_QUOTES, expand_string); ++ temp1 = expand_arith_string (substr, Q_DOUBLE_QUOTES); + *e1p = evalexp (temp1, &expok); + free (temp1); + if (expok == 0) +@@ -5293,7 +5300,7 @@ { - vtype = VT_ARRAYMEMBER; - *varp = v; -diff -Naur bash-3.0.orig/tests/array.right bash-3.0/tests/array.right ---- bash-3.0.orig/tests/array.right 2003-10-05 03:25:10.000000000 +0000 -+++ bash-3.0/tests/array.right 2005-01-08 05:40:53.582965800 +0000 -@@ -170,8 +170,8 @@ - three five seven - positive offset - expect five seven - five seven --negative offset - expect five seven --five seven -+negative offset to unset element - expect seven -+seven - positive offset 2 - expect seven - seven - negative offset 2 - expect seven -diff -Naur bash-3.0.orig/tests/array.tests bash-3.0/tests/array.tests ---- bash-3.0.orig/tests/array.tests 2003-10-05 03:25:00.000000000 +0000 -+++ bash-3.0/tests/array.tests 2005-01-08 05:40:53.580966104 +0000 -@@ -322,7 +322,7 @@ - - echo positive offset - expect five seven - echo ${av[@]:5:2} --echo negative offset - expect five seven -+echo negative offset to unset element - expect seven - echo ${av[@]: -2:2} - - echo positive offset 2 - expect seven -diff -Naur bash-3.0.orig/tests/dbg-support.tests bash-3.0/tests/dbg-support.tests ---- bash-3.0.orig/tests/dbg-support.tests 2003-03-25 20:33:03.000000000 +0000 -+++ bash-3.0/tests/dbg-support.tests 2005-01-08 05:40:02.065797600 +0000 -@@ -62,8 +62,8 @@ - trap 'print_debug_trap $LINENO' DEBUG - trap 'print_return_trap $LINENO' RETURN - --# Funcname is now an array. Vanilla Bash 2.05 doesn't have FUNCNAME array. --echo "FUNCNAME" ${FUNCNAME[0]} -+# Funcname is now an array, but you still can't see it outside a function -+echo "FUNCNAME" ${FUNCNAME[0]:-main} - - # We should trace into the below. - # Start easy with a simple function. -diff -Naur bash-3.0.orig/tests/errors.right bash-3.0/tests/errors.right ---- bash-3.0.orig/tests/errors.right 2004-05-28 02:26:03.000000000 +0000 -+++ bash-3.0/tests/errors.right 2005-01-08 05:40:04.502427176 +0000 -@@ -85,7 +85,7 @@ - ./errors.tests: line 213: /bin/sh + 0: syntax error: operand expected (error token is "/bin/sh + 0") - ./errors.tests: line 216: trap: NOSIG: invalid signal specification - ./errors.tests: line 219: trap: -s: invalid option --trap: usage: trap [-lp] [[arg] signal_spec ...] -+trap: usage: trap [-lp] [arg signal_spec ...] - ./errors.tests: line 225: return: can only `return' from a function or sourced script - ./errors.tests: line 229: break: 0: loop count out of range - ./errors.tests: line 233: continue: 0: loop count out of range -diff -Naur bash-3.0.orig/variables.c bash-3.0/variables.c ---- bash-3.0.orig/variables.c 2004-07-04 17:57:26.000000000 +0000 -+++ bash-3.0/variables.c 2005-01-08 05:40:01.842831496 +0000 -@@ -1419,11 +1419,11 @@ - v = init_dynamic_array_var ("GROUPS", get_groupset, null_array_assign, att_noassign); - - # if defined (DEBUGGER) -- v = init_dynamic_array_var ("BASH_ARGC", get_self, null_array_assign, (att_invisible|att_noassign)); -- v = init_dynamic_array_var ("BASH_ARGV", get_self, null_array_assign, (att_invisible|att_noassign)); -+ v = init_dynamic_array_var ("BASH_ARGC", get_self, null_array_assign, att_noassign); -+ v = init_dynamic_array_var ("BASH_ARGV", get_self, null_array_assign, att_noassign); - # endif /* DEBUGGER */ -- v = init_dynamic_array_var ("BASH_SOURCE", get_self, null_array_assign, (att_invisible|att_noassign)); -- v = init_dynamic_array_var ("BASH_LINENO", get_self, null_array_assign, (att_invisible|att_noassign)); -+ v = init_dynamic_array_var ("BASH_SOURCE", get_self, null_array_assign, att_noassign); -+ v = init_dynamic_array_var ("BASH_LINENO", get_self, null_array_assign, att_noassign); - #endif + t++; + temp2 = savestring (t); +- temp1 = expand_string_if_necessary (temp2, Q_DOUBLE_QUOTES, expand_string); ++ temp1 = expand_arith_string (temp2, Q_DOUBLE_QUOTES); + free (temp2); + t[-1] = ':'; + *e2p = evalexp (temp1, &expok); +@@ -6435,7 +6442,7 @@ + temp2[t_index] = '\0'; + + /* Expand variables found inside the expression. */ +- temp1 = expand_string_if_necessary (temp2, Q_DOUBLE_QUOTES, expand_string); ++ temp1 = expand_arith_string (temp2, Q_DOUBLE_QUOTES); + free (temp2); + + arithsub: +@@ -6477,7 +6484,7 @@ + zindex = t_index; + + /* Do initial variable expansion. */ +- temp1 = expand_string_if_necessary (temp, Q_DOUBLE_QUOTES, expand_string); ++ temp1 = expand_arith_string (temp, Q_DOUBLE_QUOTES); + + goto arithsub; + +@@ -6795,6 +6802,12 @@ + if (temp && *temp && t_index > 0) + { + temp1 = bash_tilde_expand (temp, tflag); ++ if (temp1 && *temp1 == '~' && STREQ (temp, temp1)) ++ { ++ FREE (temp); ++ FREE (temp1); ++ goto add_character; /* tilde expansion failed */ ++ } + free (temp); + temp = temp1; + sindex += t_index; +--- bash-3.1.orig/subst.h 2004-11-07 12:12:28.000000000 -0800 ++++ bash-3.1/subst.h 2006-04-19 15:59:29.000000000 -0700 +@@ -151,6 +151,9 @@ + extern char *expand_string_unsplit_to_string __P((char *, int)); + extern char *expand_assignment_string_to_string __P((char *, int)); + ++/* Expand an arithmetic expression string */ ++extern char *expand_arith_string __P((char *, int)); ++ + /* De-quoted quoted characters in STRING. */ + extern char *dequote_string __P((char *)); - v = init_funcname_var (); -@@ -1599,7 +1599,10 @@ - /* local foo; local foo; is a no-op. */ - old_var = find_variable (name); - if (old_var && local_p (old_var) && old_var->context == variable_context) -- return (old_var); -+ { -+ VUNSETATTR (old_var, att_invisible); -+ return (old_var); -+ } +--- bash-3.1.orig/variables.c 2005-11-12 18:22:37.000000000 -0800 ++++ bash-3.1/variables.c 2006-04-19 15:58:34.000000000 -0700 +@@ -860,9 +860,11 @@ + { + char val[INT_STRLEN_BOUND(int) + 1], *v; + ++#if defined (READLINE) + /* If we are currently assigning to LINES or COLUMNS, don't do anything. */ + if (winsize_assignment) + return; ++#endif - was_tmpvar = old_var && tempvar_p (old_var); - if (was_tmpvar) + v = inttostr (lines, val, sizeof (val)); + bind_variable ("LINES", v, 0);