diff options
| author | Chet Ramey <chet.ramey@case.edu> | 2011-11-21 20:49:12 -0500 |
|---|---|---|
| committer | Chet Ramey <chet.ramey@case.edu> | 2011-11-21 20:49:12 -0500 |
| commit | 89a92869e56aba4e4cab2d639c00a86f0545c862 (patch) | |
| tree | e1cd4da50318af8ab1f3141d39d4b0b8e1e7c500 /builtins | |
| parent | 17345e5ad288f7543b77b23a25aa380eacc279f2 (diff) | |
| download | android_external_bash-89a92869e56aba4e4cab2d639c00a86f0545c862.tar.gz android_external_bash-89a92869e56aba4e4cab2d639c00a86f0545c862.tar.bz2 android_external_bash-89a92869e56aba4e4cab2d639c00a86f0545c862.zip | |
Bash-4.0 patchlevel 38
Diffstat (limited to 'builtins')
| -rw-r--r-- | builtins/declare.def | 9 | ||||
| -rw-r--r-- | builtins/exit.def | 2 | ||||
| -rw-r--r-- | builtins/fc.def | 21 | ||||
| -rw-r--r-- | builtins/read.def | 20 |
4 files changed, 38 insertions, 14 deletions
diff --git a/builtins/declare.def b/builtins/declare.def index 9931f5e..bd7d6b6 100644 --- a/builtins/declare.def +++ b/builtins/declare.def @@ -295,6 +295,13 @@ declare_internal (list, local_var) subscript_start = (char *)NULL; if (t = strchr (name, '[')) /* ] */ { + /* If offset != 0 we have already validated any array reference */ + if (offset == 0 && valid_array_reference (name) == 0) + { + sh_invalidid (name); + assign_error++; + NEXT_VARIABLE (); + } subscript_start = t; *t = '\0'; making_array_special = 1; @@ -484,7 +491,7 @@ declare_internal (list, local_var) } /* declare -a name[[n]] or declare name[n] makes name an indexed array variable. */ - else if ((making_array_special || (flags_on & att_array)) && array_p (var) == 0) + else if ((making_array_special || (flags_on & att_array)) && array_p (var) == 0 && assoc_p (var) == 0) var = convert_var_to_array (var); #endif /* ARRAY_VARS */ diff --git a/builtins/exit.def b/builtins/exit.def index edf8db0..34728eb 100644 --- a/builtins/exit.def +++ b/builtins/exit.def @@ -113,7 +113,7 @@ exit_or_logout (list) for (i = stopmsg = 0; i < js.j_jobslots; i++) if (jobs[i] && STOPPED (i)) stopmsg = JSTOPPED; - else if (check_jobs_at_exit && stopmsg == 0 && RUNNING (i)) + else if (check_jobs_at_exit && stopmsg == 0 && jobs[i] && RUNNING (i)) stopmsg = JRUNNING; if (stopmsg == JSTOPPED) diff --git a/builtins/fc.def b/builtins/fc.def index 22425d7..a378d9d 100644 --- a/builtins/fc.def +++ b/builtins/fc.def @@ -88,6 +88,7 @@ extern int errno; extern int current_command_line_count; extern int literal_history; extern int posixly_correct; +extern int subshell_environment, interactive_shell; extern int unlink __P((const char *)); @@ -172,7 +173,7 @@ fc_builtin (list) register int i; register char *sep; int numbering, reverse, listing, execute; - int histbeg, histend, last_hist, retval, opt; + int histbeg, histend, last_hist, retval, opt, rh; FILE *stream; REPL *rlist, *rl; char *ename, *command, *newcom, *fcedit; @@ -275,6 +276,8 @@ fc_builtin (list) fprintf (stderr, "%s\n", command); fc_replhist (command); /* replace `fc -s' with command */ + /* Posix says that the re-executed commands should be entered into the + history. */ return (parse_and_execute (command, "fc", SEVAL_NOHIST)); } @@ -293,7 +296,12 @@ fc_builtin (list) line was actually added (HISTIGNORE may have caused it to not be), so we check hist_last_line_added. */ - last_hist = i - remember_on_history - hist_last_line_added; + /* Even though command substitution through parse_and_execute turns off + remember_on_history, command substitution in a shell when set -o history + 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); + last_hist = i - rh - hist_last_line_added; if (list) { @@ -456,7 +464,7 @@ fc_gethnum (command, hlist) char *command; HIST_ENTRY **hlist; { - int sign, n, clen; + int sign, n, clen, rh; register int i, j; register char *s; @@ -472,7 +480,12 @@ fc_gethnum (command, hlist) line was actually added (HISTIGNORE may have caused it to not be), so we check hist_last_line_added. This needs to agree with the calculation of last_hist in fc_builtin above. */ - i -= remember_on_history + hist_last_line_added; + /* Even though command substitution through parse_and_execute turns off + remember_on_history, command substitution in a shell when set -o history + 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; /* No specification defaults to most recent command. */ if (command == NULL) diff --git a/builtins/read.def b/builtins/read.def index fb4366f..8fc5647 100644 --- a/builtins/read.def +++ b/builtins/read.def @@ -369,14 +369,14 @@ read_builtin (list) code = setjmp (alrmbuf); if (code) { -#if 0 + /* Tricky. The top of the unwind-protect stack is the free of + input_string. We want to run all the rest and use input_string, + so we have to remove it from the stack. */ + remove_unwind_protect (); run_unwind_frame ("read_builtin"); - return (EXECUTION_FAILURE); -#else input_string[i] = '\0'; /* make sure it's terminated */ - retval = 128+SIGALRM;; + retval = 128+SIGALRM; goto assign_vars; -#endif } old_alrm = set_signal_handler (SIGALRM, sigalrm); add_unwind_protect (reset_alarm, (char *)NULL); @@ -601,14 +601,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. */ @@ -763,7 +764,10 @@ assign_vars: if (*input_string == 0) tofree = input_string = t; else - input_string = strip_trailing_ifs_whitespace (t1, ifs_chars, saw_escape); + { + input_string = strip_trailing_ifs_whitespace (t1, ifs_chars, saw_escape); + tofree = t; + } } #endif |
