commit bash-20090401 snapshot

This commit is contained in:
Chet Ramey
2011-12-08 20:07:17 -05:00
parent c302751c7b
commit 5ccad77957
19 changed files with 789 additions and 652 deletions
+26 -1
View File
@@ -7801,7 +7801,7 @@ builtins/fc.def
set -o history has been enabled (interactive or not) should use it
in the last_hist calculation as if it were on. Same calculation
in fc_gethnum and fc_builtin. Fixes bug reported by
<smallnow@gmail.com>
Ian Kelling <smallnow@gmail.com>
sig.c
- change termsig_sighandler to terminate immediately if it gets called
@@ -7830,3 +7830,28 @@ array.c
before shifting in the new element 0
- array_shift needs to use element_index(a->head->prev) to set the
max_index, not a simple decrement, to deal with sparse arrays
4/1
---
bashline.c
- in bash_dequote_filename, return right away after copying the
backslash if the last character in the string to be expanded
is a backslash. The old code copied an extra NUL and overwrote
the bounds checking. Fixes bug reported by Shawn Starr
https://bugzilla.redhat.com/show_bug.cgi?id=488649
4/3
---
subst.c
- in pat_subst.c, make sure to copy one character from the input
string in the case of a null pattern match, since we substitute
on the null match and then increment past the current character.
Not doing this means that each character of the original string
is replaced because of the null matches. Fixes debian bug
reported bhy Louis-David Mitterrand <ldm@apartia.fr>
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=522160
lib/sh/winsize.c
- incorporate contents of readline/rlwinsize.h to get all the various
system dependencies right when trying to find TIOCGWINSZ. Fixes
bug reported by Dan Price <dp@eng.sun.com>
+23 -1
View File
@@ -7801,7 +7801,7 @@ builtins/fc.def
set -o history has been enabled (interactive or not) should use it
in the last_hist calculation as if it were on. Same calculation
in fc_gethnum and fc_builtin. Fixes bug reported by
<smallnow@gmail.com>
Ian Kelling <smallnow@gmail.com>
sig.c
- change termsig_sighandler to terminate immediately if it gets called
@@ -7828,3 +7828,25 @@ array.c
invalidated where necessary in other functions
- array_rshift needs to set max_index to 0 if the array was empty
before shifting in the new element 0
- array_shift needs to use element_index(a->head->prev) to set the
max_index, not a simple decrement, to deal with sparse arrays
4/1
---
bashline.c
- in bash_dequote_filename, return right away after copying the
backslash if the last character in the string to be expanded
is a backslash. The old code copied an extra NUL and overwrote
the bounds checking. Fixes bug reported by Shawn Starr
https://bugzilla.redhat.com/show_bug.cgi?id=488649
4/3
---
subst.c
- in pat_subst.c, make sure to copy one character from the input
string in the case of a null pattern match, since we substitute
on the null match and then increment past the current character.
Not doing this means that each character of the original string
is replaced because of the null matches. Fixes debian bug
reported bhy Louis-David Mitterrand <ldm@apartia.fr>
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=522160
+1 -1
View File
@@ -3225,7 +3225,7 @@ bash_dequote_filename (text, quote_char)
*r++ = *++p;
if (*p == '\0')
break;
return ret; /* XXX - was break; */
continue;
}
/* Close quote. */
+3 -1
View File
@@ -3592,7 +3592,10 @@ execute_simple_command (simple_command, pipe_in, pipe_out, async, fds_to_close)
begin_unwind_frame ("simple-command");
if (echo_command_at_execute)
{
itrace("execute_simple_command: xtrace_print_word_list: %s", words->word->word);
xtrace_print_word_list (words, 1);
}
builtin = (sh_builtin_func_t *)NULL;
func = (SHELL_VAR *)NULL;
@@ -4005,7 +4008,6 @@ execute_function (var, words, flags, fds_to_close, async, subshell)
array_push (bash_source_a, sfile);
t = itos (executing_line_number ());
itrace("execute_function (%s): pushing %s %s", this_shell_function->name, sfile, t);
array_push (bash_lineno_a, t);
free (t);
#endif
+26 -9
View File
@@ -30,16 +30,33 @@
#include <sys/ioctl.h>
#if !defined (STRUCT_WINSIZE_IN_SYS_IOCTL)
/* For struct winsize on SCO */
/* sys/ptem.h has winsize but needs mblk_t from sys/stream.h */
# if defined (HAVE_SYS_PTEM_H) && defined (TIOCGWINSZ) && defined (SIGWINCH)
# if defined (HAVE_SYS_STREAM_H)
# include <sys/stream.h>
# endif
/* Try to find the definitions of `struct winsize' and TIOGCWINSZ */
#if defined (GWINSZ_IN_SYS_IOCTL) && !defined (TIOCGWINSZ)
# include <sys/ioctl.h>
#endif /* GWINSZ_IN_SYS_IOCTL && !TIOCGWINSZ */
#if defined (STRUCT_WINSIZE_IN_TERMIOS) && !defined (STRUCT_WINSIZE_IN_SYS_IOCTL)
# include <termios.h>
#endif /* STRUCT_WINSIZE_IN_TERMIOS && !STRUCT_WINSIZE_IN_SYS_IOCTL */
/* Not in either of the standard places, look around. */
#if !defined (STRUCT_WINSIZE_IN_TERMIOS) && !defined (STRUCT_WINSIZE_IN_SYS_IOCTL)
# if defined (HAVE_SYS_STREAM_H)
# include <sys/stream.h>
# endif /* HAVE_SYS_STREAM_H */
# if defined (HAVE_SYS_PTEM_H) /* SVR4.2, at least, has it here */
# include <sys/ptem.h>
# endif /* HAVE_SYS_PTEM_H && TIOCGWINSZ && SIGWINCH */
#endif /* !STRUCT_WINSIZE_IN_SYS_IOCTL */
# define _IO_PTEM_H /* work around SVR4.2 1.1.4 bug */
# endif /* HAVE_SYS_PTEM_H */
# if defined (HAVE_SYS_PTE_H) /* ??? */
# include <sys/pte.h>
# endif /* HAVE_SYS_PTE_H */
#endif /* !STRUCT_WINSIZE_IN_TERMIOS && !STRUCT_WINSIZE_IN_SYS_IOCTL */
#if defined (M_UNIX) && !defined (_SCO_DS) && !defined (tcflow)
# define tcflow(fd, action) ioctl(fd, TCXONC, action)
#endif
#include <stdio.h>
+83
View File
@@ -0,0 +1,83 @@
/* winsize.c - handle window size changes and information. */
/* Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Bash is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Bash. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <stdc.h>
#include "bashtypes.h"
#if defined (HAVE_UNISTD_H)
# include <unistd.h>
#endif
#include <sys/ioctl.h>
#if !defined (STRUCT_WINSIZE_IN_SYS_IOCTL)
/* For struct winsize on SCO */
/* sys/ptem.h has winsize but needs mblk_t from sys/stream.h */
# if defined (HAVE_SYS_PTEM_H) && defined (TIOCGWINSZ) && defined (SIGWINCH)
# if defined (HAVE_SYS_STREAM_H)
# include <sys/stream.h>
# endif
# include <sys/ptem.h>
# endif /* HAVE_SYS_PTEM_H && TIOCGWINSZ && SIGWINCH */
#endif /* !STRUCT_WINSIZE_IN_SYS_IOCTL */
#include <stdio.h>
/* Return the fd from which we are actually getting input. */
#define input_tty() (shell_tty != -1) ? shell_tty : fileno (stderr)
#if !defined (errno)
extern int errno;
#endif /* !errno */
extern int shell_tty;
#if defined (READLINE)
extern void rl_set_screen_size __P((int, int));
#endif
extern void sh_set_lines_and_columns __P((int, int));
void
get_new_window_size (from_sig, rp, cp)
int from_sig;
int *rp, *cp;
{
#if defined (TIOCGWINSZ)
struct winsize win;
int tty;
tty = input_tty ();
if (tty >= 0 && (ioctl (tty, TIOCGWINSZ, &win) == 0) &&
win.ws_row > 0 && win.ws_col > 0)
{
sh_set_lines_and_columns (win.ws_row, win.ws_col);
#if defined (READLINE)
rl_set_screen_size (win.ws_row, win.ws_col);
if (rp)
*rp = win.ws_row;
if (cp)
*cp = win.ws_col;
#endif
}
#endif
}
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
+204 -342
View File
File diff suppressed because it is too large Load Diff
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
+354 -284
View File
File diff suppressed because it is too large Load Diff
+7 -1
View File
@@ -6027,7 +6027,13 @@ pat_subst (string, pat, rep, mflags)
break;
if (s == e)
e++, str++; /* avoid infinite recursion on zero-length match */
{
/* On a zero-length match, make sure we copy one character, since
we increment one character to avoid infinite recursion. */
RESIZE_MALLOCED_BUFFER (ret, rptr, 1, rsize, 64);
ret[rptr++] = *str++;
e++; /* avoid infinite recursion on zero-length match */
}
}
/* Now copy the unmatched portion of the input string */
+33 -6
View File
@@ -2058,7 +2058,7 @@ string_list_dollar_at (list, quoted)
#if 0
tlist = ((quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) || (ifs && *ifs == 0))
#else
tlist = (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES))
tlist = (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES|Q_PATQUOTE))
#endif
? quote_list (list)
: list_quote_escapes (list);
@@ -4313,6 +4313,12 @@ expand_word_unsplit (word, quoted)
WORD_LIST *result;
expand_no_split_dollar_star = 1;
#if defined (HANDLE_MULTIBYTE)
if (ifs_firstc[0] == 0)
#else
if (ifs_firstc == 0)
#endif
word->flags |= W_NOSPLIT;
result = call_expand_word_internal (word, quoted, 0, (int *)NULL, (int *)NULL);
expand_no_split_dollar_star = 0;
@@ -4320,13 +4326,26 @@ expand_word_unsplit (word, quoted)
}
/* Perform shell expansions on WORD, but do not perform word splitting or
quote removal on the result. */
quote removal on the result. Virtually identical to expand_word_unsplit;
could be combined if implementations don't diverge. */
WORD_LIST *
expand_word_leave_quoted (word, quoted)
WORD_DESC *word;
int quoted;
{
return (call_expand_word_internal (word, quoted, 0, (int *)NULL, (int *)NULL));
WORD_LIST *result;
expand_no_split_dollar_star = 1;
#if defined (HANDLE_MULTIBYTE)
if (ifs_firstc[0] == 0)
#else
if (ifs_firstc == 0)
#endif
word->flags |= W_NOSPLIT;
result = call_expand_word_internal (word, quoted, 0, (int *)NULL, (int *)NULL);
expand_no_split_dollar_star = 0;
return result;
}
#if defined (PROCESS_SUBSTITUTION)
@@ -6008,7 +6027,14 @@ pat_subst (string, pat, rep, mflags)
break;
if (s == e)
e++, str++; /* avoid infinite recursion on zero-length match */
{
/* On a zero-length match, make sure we copy one character, since
we increment one character below to avoid infinite recursion. */
RESIZE_MALLOCED_BUFFER (ret, rptr, 1, rsize, 64);
strncpy (ret + rptr, str, 1);
rptr += 1;
e++, str++; /* avoid infinite recursion on zero-length match */
}
}
/* Now copy the unmatched portion of the input string */
@@ -7005,14 +7031,14 @@ param_expand (string, sindex, quoted, expanded_something,
even if it's quoted. */
if ((quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) && list == 0)
temp = (char *)NULL;
else if (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES))
else if (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES|Q_PATQUOTE))
{
/* If we have "$*" we want to make a string of the positional
parameters, separated by the first character of $IFS, and
quote the whole string, including the separators. If IFS
is unset, the parameters are separated by ' '; if $IFS is
null, the parameters are concatenated. */
temp = (quoted & Q_DOUBLE_QUOTES) ? string_list_dollar_star (list) : string_list (list);
temp = (quoted & (Q_DOUBLE_QUOTES|Q_PATQUOTE)) ? string_list_dollar_star (list) : string_list (list);
temp1 = quote_string (temp);
if (*temp == 0)
tflag |= W_HASQUOTEDNULL;
@@ -7067,6 +7093,7 @@ param_expand (string, sindex, quoted, expanded_something,
string might need it (consider "\"$@\""), but we need some
way to signal that the final split on the first character
of $IFS should be done, even though QUOTED is 1. */
/* XXX - should this test include Q_PATQUOTE? */
if (quoted_dollar_at_p && (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)))
*quoted_dollar_at_p = 1;
if (contains_dollar_at)
+20 -3
View File
@@ -4313,7 +4313,12 @@ expand_word_unsplit (word, quoted)
WORD_LIST *result;
expand_no_split_dollar_star = 1;
word->flags |= W_NOSPLIT;
#if defined (HANDLE_MULTIBYTE)
if (ifs_firstc[0] == 0)
#else
if (ifs_firstc == 0)
#endif
word->flags |= W_NOSPLIT;
result = call_expand_word_internal (word, quoted, 0, (int *)NULL, (int *)NULL);
expand_no_split_dollar_star = 0;
@@ -4331,7 +4336,12 @@ expand_word_leave_quoted (word, quoted)
WORD_LIST *result;
expand_no_split_dollar_star = 1;
word->flags |= W_NOSPLIT;
#if defined (HANDLE_MULTIBYTE)
if (ifs_firstc[0] == 0)
#else
if (ifs_firstc == 0)
#endif
word->flags |= W_NOSPLIT;
result = call_expand_word_internal (word, quoted, 0, (int *)NULL, (int *)NULL);
expand_no_split_dollar_star = 0;
@@ -6017,7 +6027,14 @@ pat_subst (string, pat, rep, mflags)
break;
if (s == e)
e++, str++; /* avoid infinite recursion on zero-length match */
{
/* On a zero-length match, make sure we copy one character, since
we increment one character below to avoid infinite recursion. */
RESIZE_MALLOCED_BUFFER (ret, rptr, 1, rsize, 64);
strncpy (ret + rptr, str, 1);
rptr += 1;
e++, str++; /* avoid infinite recursion on zero-length match */
}
}
/* Now copy the unmatched portion of the input string */
+3 -3
View File
@@ -1,6 +1,6 @@
echo "warning: UNIX versions number signals differently. If output differing" >&2
echo "warning: only in line numbers is produced, please do not consider this" >&2
echo "warning: a test failure." >&2
echo "warning: UNIX versions number signals and schedule processes differently." >&2
echo "warning: If output differing only in line numbers is produced, please" >&2
echo "warning: do not consider this a test failure." >&2
${THIS_SH} ./trap.tests > /tmp/xx 2>&1
diff /tmp/xx trap.right && rm -f /tmp/xx
+6
View File
@@ -0,0 +1,6 @@
echo "warning: UNIX versions number signals differently. If output differing" >&2
echo "warning: only in line numbers is produced, please do not consider this" >&2
echo "warning: a test failure." >&2
${THIS_SH} ./trap.tests > /tmp/xx 2>&1
diff /tmp/xx trap.right && rm -f /tmp/xx