summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChet Ramey <chet.ramey@case.edu>2011-11-21 20:57:16 -0500
committerChet Ramey <chet.ramey@case.edu>2011-11-21 20:57:16 -0500
commit30d188c2932d6ef609d894fefeb7e7b03ccff463 (patch)
tree51fa285584cb0f99c7a4d64b0b56d355a747b3e2
parent0001803f0b9523c94fa2ede48eaecb047fef4524 (diff)
downloadbash-30d188c2932d6ef609d894fefeb7e7b03ccff463.tar.gz
Bash-4.1 patchlevel 11bash-4.1.11
-rw-r--r--bashline.c2
-rw-r--r--builtins/declare.def2
-rw-r--r--builtins/fc.def22
-rw-r--r--builtins/printf.def4
-rw-r--r--builtins/read.def5
-rw-r--r--lib/readline/complete.c4
-rw-r--r--parse.y2
-rw-r--r--patchlevel.h2
-rw-r--r--print_cmd.c10
-rw-r--r--sig.c3
-rw-r--r--variables.c5
-rw-r--r--y.tab.c3
12 files changed, 49 insertions, 15 deletions
diff --git a/bashline.c b/bashline.c
index 7658771e..9b49d0b4 100644
--- a/bashline.c
+++ b/bashline.c
@@ -1680,7 +1680,7 @@ globword:
a single match (multiple matches that end up reducing the number of
characters in the common prefix are bad) will ever be returned on
regular completion. */
- if (glob_pattern_p (hint))
+ if (globpat)
{
if (state == 0)
{
diff --git a/builtins/declare.def b/builtins/declare.def
index a0ce6054..811d8e64 100644
--- a/builtins/declare.def
+++ b/builtins/declare.def
@@ -512,7 +512,7 @@ declare_internal (list, local_var)
{
/* let bind_{array,assoc}_variable take care of this. */
if (assoc_p (var))
- bind_assoc_variable (var, name, "0", value, aflags);
+ bind_assoc_variable (var, name, savestring ("0"), value, aflags);
else
bind_array_variable (name, 0, value, aflags);
}
diff --git a/builtins/fc.def b/builtins/fc.def
index a378d9de..71f468fe 100644
--- a/builtins/fc.def
+++ b/builtins/fc.def
@@ -303,6 +303,16 @@ fc_builtin (list)
rh = remember_on_history || ((subshell_environment & SUBSHELL_COMSUB) && enable_history_list);
last_hist = i - rh - hist_last_line_added;
+ /* XXX */
+ if (i == last_hist && hlist[last_hist] == 0)
+ while (last_hist >= 0 && hlist[last_hist] == 0)
+ last_hist--;
+ if (last_hist < 0)
+ {
+ sh_erange ((char *)NULL, _("history specification"));
+ return (EXECUTION_FAILURE);
+ }
+
if (list)
{
histbeg = fc_gethnum (list->word->word, hlist);
@@ -465,7 +475,7 @@ fc_gethnum (command, hlist)
HIST_ENTRY **hlist;
{
int sign, n, clen, rh;
- register int i, j;
+ register int i, j, last_hist;
register char *s;
sign = 1;
@@ -485,7 +495,15 @@ fc_gethnum (command, hlist)
has been enabled (interactive or not) should use it in the last_hist
calculation as if it were on. */
rh = remember_on_history || ((subshell_environment & SUBSHELL_COMSUB) && enable_history_list);
- i -= rh + hist_last_line_added;
+ last_hist = i - rh - hist_last_line_added;
+
+ if (i == last_hist && hlist[last_hist] == 0)
+ while (last_hist >= 0 && hlist[last_hist] == 0)
+ last_hist--;
+ if (last_hist < 0)
+ return (-1);
+
+ i = last_hist;
/* No specification defaults to most recent command. */
if (command == NULL)
diff --git a/builtins/printf.def b/builtins/printf.def
index e4476334..277566f8 100644
--- a/builtins/printf.def
+++ b/builtins/printf.def
@@ -117,7 +117,7 @@ extern int errno;
else if (have_fieldwidth) \
nw = vflag ? vbprintf (f, fieldwidth, func) : printf (f, fieldwidth, func); \
else if (have_precision) \
- nw = vflag ? vbprintf (f, precision, func) : printf (f, fieldwidth, func); \
+ nw = vflag ? vbprintf (f, precision, func) : printf (f, precision, func); \
else \
nw = vflag ? vbprintf (f, func) : printf (f, func); \
tw += nw; \
@@ -172,7 +172,7 @@ extern int asprintf __P((char **, const char *, ...)) __attribute__((__format__
#endif
#if !HAVE_VSNPRINTF
-extern int vsnprintf __P((char *, size_t, const char *, ...)) __attribute__((__format__ (printf, 3, 4)));
+extern int vsnprintf __P((char *, size_t, const char *, va_list)) __attribute__((__format__ (printf, 3, 0)));
#endif
static void printf_erange __P((char *));
diff --git a/builtins/read.def b/builtins/read.def
index 1ef9142d..20860bef 100644
--- a/builtins/read.def
+++ b/builtins/read.def
@@ -615,14 +615,15 @@ add_char:
if (unbuffered_read == 0)
zsyncfd (fd);
- interrupt_immediately--;
- terminate_immediately--;
discard_unwind_frame ("read_builtin");
retval = eof ? EXECUTION_FAILURE : EXECUTION_SUCCESS;
assign_vars:
+ interrupt_immediately--;
+ terminate_immediately--;
+
#if defined (ARRAY_VARS)
/* If -a was given, take the string read, break it into a list of words,
an assign them to `arrayname' in turn. */
diff --git a/lib/readline/complete.c b/lib/readline/complete.c
index ad9ca051..bda22048 100644
--- a/lib/readline/complete.c
+++ b/lib/readline/complete.c
@@ -2138,7 +2138,7 @@ rl_filename_completion_function (text, state)
All other entries except "." and ".." match. */
if (filename_len == 0)
{
- if (_rl_match_hidden_files == 0 && HIDDEN_FILE (entry->d_name))
+ if (_rl_match_hidden_files == 0 && HIDDEN_FILE (convfn))
continue;
if (convfn[0] != '.' ||
@@ -2219,7 +2219,7 @@ rl_filename_completion_function (text, state)
temp[dirlen++] = '/';
}
- strcpy (temp + dirlen, entry->d_name);
+ strcpy (temp + dirlen, convfn);
}
else
temp = savestring (convfn);
diff --git a/parse.y b/parse.y
index 2b47ff80..4420d151 100644
--- a/parse.y
+++ b/parse.y
@@ -5152,7 +5152,7 @@ decode_prompt_string (string)
{
t = strrchr (t_string, '/');
if (t)
- strcpy (t_string, t + 1);
+ memmove (t_string, t + 1, strlen (t));
}
}
#undef ROOT_PATH
diff --git a/patchlevel.h b/patchlevel.h
index 2af2f568..ff30881e 100644
--- a/patchlevel.h
+++ b/patchlevel.h
@@ -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 11
#endif /* _PATCHLEVEL_H_ */
diff --git a/print_cmd.c b/print_cmd.c
index 9a41dcbd..b8fb0a2d 100644
--- a/print_cmd.c
+++ b/print_cmd.c
@@ -113,6 +113,12 @@ FILE *xtrace_fp = 0;
#define CHECK_XTRACE_FP xtrace_fp = (xtrace_fp ? xtrace_fp : stderr)
+#define PRINT_DEFERRED_HEREDOCS(x) \
+ do { \
+ if (deferred_heredocs) \
+ print_deferred_heredocs (x); \
+ } while (0)
+
/* Non-zero means the stuff being printed is inside of a function def. */
static int inside_function_def;
static int skip_this_indent;
@@ -560,13 +566,15 @@ print_for_command (for_command)
FOR_COM *for_command;
{
print_for_command_head (for_command);
-
cprintf (";");
newline ("do\n");
+
indentation += indentation_amount;
make_command_string_internal (for_command->action);
+ PRINT_DEFERRED_HEREDOCS ("");
semicolon ();
indentation -= indentation_amount;
+
newline ("done");
}
diff --git a/sig.c b/sig.c
index a217b894..be9676fd 100644
--- a/sig.c
+++ b/sig.c
@@ -655,6 +655,9 @@ set_signal_handler (sig, handler)
act.sa_flags |= SA_INTERRUPT; /* XXX */
else
act.sa_flags |= SA_RESTART; /* XXX */
+#else
+ if (sig == SIGCHLD)
+ act.sa_flags |= SA_RESTART;
#endif
sigemptyset (&act.sa_mask);
sigemptyset (&oact.sa_mask);
diff --git a/variables.c b/variables.c
index d1da8f67..ebe4013d 100644
--- a/variables.c
+++ b/variables.c
@@ -3808,6 +3808,11 @@ push_func_var (data)
if (tempvar_p (var) && (posixly_correct || (var->attributes & att_propagate)))
{
+ /* Make sure we have a hash table to store the variable in while it is
+ being propagated down to the global variables table. Create one if
+ we have to */
+ if ((vc_isfuncenv (shell_variables) || vc_istempenv (shell_variables)) && shell_variables->table == 0)
+ shell_variables->table = hash_create (0);
/* XXX - should we set v->context here? */
v = bind_variable_internal (var->name, value_cell (var), shell_variables->table, 0, 0);
if (shell_variables == global_variables)
diff --git a/y.tab.c b/y.tab.c
index d7025546..9a1f4da3 100644
--- a/y.tab.c
+++ b/y.tab.c
@@ -7481,7 +7481,7 @@ decode_prompt_string (string)
{
t = strrchr (t_string, '/');
if (t)
- strcpy (t_string, t + 1);
+ memmove (t_string, t + 1, strlen (t));
}
}
#undef ROOT_PATH
@@ -8243,4 +8243,3 @@ set_line_mbstate ()
}
}
#endif /* HANDLE_MULTIBYTE */
-