commit bash-20151218 snapshot

This commit is contained in:
Chet Ramey
2015-12-21 10:41:17 -05:00
parent 3f2135aaac
commit 25340ead08
7 changed files with 88 additions and 43 deletions
+23
View File
@@ -10153,3 +10153,26 @@ lib/readline/display.c
- update_line: update code that attempts to compute where we are in
the new line buffer. Fixes `vt100' bug reported to bug-readline by
Per Bothner <per@bothner.com>
12/18
-----
execute_cmd.c
- execute_function: unwind-protect and restore BASH_ARGC and BASH_ARGV
- restore_funcarray_state: now global
execute_cmd.h
- make func_array_state type global, add extern function declaration
for restore_funcarray_state
builtins/evalfile.c
- _evalfile: use restore_funcarray_state and pop_args as unwind-protects
to restore BASH_{SOURCE,LINENO,ARGC,ARGV} and FUNCNAME on interrupts.
Fixes bug reported back on 11/10 by Grisha Levit
<grishalevit@gmail.com>
12/20
-----
lib/readline/isearch.c
- _rl_isearch_dispatch: after removing the only character from the
search string with DEL, leaving the search string empty, don't match
the previous line if we didn't have a match before
+26 -20
View File
@@ -94,6 +94,7 @@ _evalfile (filename, flags)
#if defined (ARRAY_VARS)
SHELL_VAR *funcname_v, *nfv, *bash_source_v, *bash_lineno_v;
ARRAY *funcname_a, *bash_source_a, *bash_lineno_a;
struct func_array_state *fa;
# if defined (DEBUGGER)
SHELL_VAR *bash_argv_v, *bash_argc_v;
ARRAY *bash_argv_a, *bash_argc_a;
@@ -243,6 +244,17 @@ file_error_and_exit:
array_push (bash_lineno_a, t);
free (t);
array_push (funcname_a, "source"); /* not exactly right */
fa = (struct func_array_state *)xmalloc (sizeof (struct func_array_state));
fa->source_a = bash_source_a;
fa->source_v = bash_source_v;
fa->lineno_a = bash_lineno_a;
fa->lineno_v = bash_lineno_v;
fa->funcname_a = funcname_a;
fa->funcname_v = funcname_v;
if (flags & FEVAL_UNWINDPROT)
add_unwind_protect (restore_funcarray_state, fa);
# if defined (DEBUGGER)
/* Have to figure out a better way to do this when `source' is supplied
arguments */
@@ -251,6 +263,8 @@ file_error_and_exit:
array_push (bash_argv_a, (char *)filename);
tt[0] = '1'; tt[1] = '\0';
array_push (bash_argc_a, tt);
if (flags & FEVAL_UNWINDPROT)
add_unwind_protect (pop_args, 0);
}
# endif
#endif
@@ -280,31 +294,23 @@ file_error_and_exit:
{
if (flags & FEVAL_NONINT)
interactive = old_interactive;
#if defined (ARRAY_VARS)
restore_funcarray_state (fa);
# if defined (DEBUGGER)
if ((flags & FEVAL_NOPUSHARGS) == 0)
{
/* Don't need to call pop_args here until we do something better
when source is passed arguments (see above). */
array_pop (bash_argc_a);
array_pop (bash_argv_a);
}
# endif
#endif
return_catch_flag--;
sourcelevel--;
COPY_PROCENV (old_return_catch, return_catch);
}
#if defined (ARRAY_VARS)
/* These two variables cannot be unset, and cannot be affected by the
sourced file. */
array_pop (bash_source_a);
array_pop (bash_lineno_a);
/* FUNCNAME can be unset, and so can potentially be changed by the
sourced file. */
GET_ARRAY_FROM_VAR ("FUNCNAME", nfv, funcname_a);
if (nfv == funcname_v)
array_pop (funcname_a);
# if defined (DEBUGGER)
if ((flags & FEVAL_NOPUSHARGS) == 0)
{
array_pop (bash_argc_a);
array_pop (bash_argv_a);
}
# endif
#endif
/* If we end up with EOF after sourcing a file, which can happen when the file
doesn't end with a newline, pretend that it did. */
if (current_token == yacc_EOF)
+12 -19
View File
@@ -105,18 +105,6 @@ extern int errno;
# include <mbstr.h> /* mbschr */
#endif
#if defined (ARRAY_VARS)
struct func_array_state
{
ARRAY *funcname_a;
SHELL_VAR *funcname_v;
ARRAY *source_a;
SHELL_VAR *source_v;
ARRAY *lineno_a;
SHELL_VAR *lineno_v;
};
#endif
extern int dollar_dollar_pid;
extern int posixly_correct;
extern int expand_aliases;
@@ -4504,7 +4492,7 @@ maybe_restore_getopt_state (gs)
}
#if defined (ARRAY_VARS)
static void
void
restore_funcarray_state (fa)
struct func_array_state *fa;
{
@@ -4674,7 +4662,11 @@ execute_function (var, words, flags, fds_to_close, async, subshell)
/* Update BASH_ARGV and BASH_ARGC */
if (debugging_mode)
push_args (words->next);
{
push_args (words->next);
if (subshell == 0)
add_unwind_protect (pop_args, 0);
}
/* Number of the line on which the function body starts. */
line_number = function_line_number = tc->line;
@@ -4734,10 +4726,6 @@ execute_function (var, words, flags, fds_to_close, async, subshell)
showing_function_line = 0;
}
/* Restore BASH_ARGC and BASH_ARGV */
if (debugging_mode)
pop_args ();
/* If we have a local copy of OPTIND, note it in the saved getopts state. */
gv = find_variable ("OPTIND");
if (gv && gv->context == variable_context)
@@ -4747,7 +4735,12 @@ execute_function (var, words, flags, fds_to_close, async, subshell)
run_unwind_frame ("function_calling");
#if defined (ARRAY_VARS)
else
restore_funcarray_state (fa);
{
restore_funcarray_state (fa);
/* Restore BASH_ARGC and BASH_ARGV */
if (debugging_mode)
pop_args ();
}
#endif
if (variable_context == 0 || this_shell_function == 0)
+15 -1
View File
@@ -1,6 +1,6 @@
/* execute_cmd.h - functions from execute_cmd.c. */
/* Copyright (C) 1993-2009 Free Software Foundation, Inc.
/* Copyright (C) 1993-2015 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -23,6 +23,18 @@
#include "stdc.h"
#if defined (ARRAY_VARS)
struct func_array_state
{
ARRAY *funcname_a;
SHELL_VAR *funcname_v;
ARRAY *source_a;
SHELL_VAR *source_v;
ARRAY *lineno_a;
SHELL_VAR *lineno_v;
};
#endif
extern struct fd_bitmap *new_fd_bitmap __P((int));
extern void dispose_fd_bitmap __P((struct fd_bitmap *));
extern void close_fd_bitmap __P((struct fd_bitmap *));
@@ -65,4 +77,6 @@ extern void coproc_unsetvars __P((struct coproc *));
extern void close_all_files __P((void));
#endif
extern void restore_funcarray_state __P((struct func_array_state *));
#endif /* _EXECUTE_CMD_H_ */
-1
View File
@@ -3565,7 +3565,6 @@ itrace("waitchld: waitpid returns %d block = %d children_exited = %d", pid, bloc
{
if (posixly_correct && this_shell_builtin && this_shell_builtin == wait_builtin)
{
itrace("waitchld: this_shell_builtin == wait_builtin got %d children wait_intr_flag = %d", children_exited, wait_intr_flag);
interrupt_immediately = 0;
/* This was trap_handler (SIGCHLD) but that can lose traps if
children_exited > 1 */
+11 -1
View File
@@ -560,8 +560,12 @@ add_character:
if (wstart >= 0)
cxt->search_string[cxt->search_string_index = wstart] = '\0';
else
rl_ding ();
cxt->search_string[cxt->search_string_index = 0] = '\0';
}
if (cxt->search_string_index == 0)
rl_ding ();
break;
case -4: /* C-G, abort */
@@ -654,6 +658,12 @@ add_character:
for (cxt->sflags &= ~(SF_FOUND|SF_FAILED);; )
{
if (cxt->search_string_index == 0)
{
cxt->sflags |= SF_FAILED;
break;
}
limit = cxt->sline_len - cxt->search_string_index + 1;
/* Search the current line. */
+1 -1
View File
@@ -1,4 +1,4 @@
BUILD_DIR=/usr/local/build/bash/bash-current
BUILD_DIR=/usr/local/build/chet/bash/bash-current
THIS_SH=$BUILD_DIR/bash
PATH=$PATH:$BUILD_DIR