diff options
author | Chet Ramey <chet.ramey@case.edu> | 2011-12-08 20:12:41 -0500 |
---|---|---|
committer | Chet Ramey <chet.ramey@case.edu> | 2011-12-08 20:12:41 -0500 |
commit | 0527c9035cae5c3fa84393a8eb48ec1582120c7e (patch) | |
tree | e574afee93ca579542edea58a59f2a82f284bd6d | |
parent | 6669f0e53825adb822456f2c74cf8f102e501cf5 (diff) | |
download | bash-0527c9035cae5c3fa84393a8eb48ec1582120c7e.tar.gz |
commit bash-20090715 snapshot
-rw-r--r-- | CWRU/CWRU.chlog | 21 | ||||
-rw-r--r-- | CWRU/CWRU.chlog~ | 29 | ||||
-rw-r--r-- | bashline.c | 4 | ||||
-rw-r--r-- | bashline.c~ | 16 | ||||
-rw-r--r-- | ddd1~ | 171 | ||||
-rw-r--r-- | lib/readline/readline.c | 2 | ||||
-rw-r--r-- | subst.c | 17 | ||||
-rw-r--r-- | subst.c~ | 17 | ||||
-rw-r--r-- | trap.c | 12 | ||||
-rw-r--r-- | trap.c~ | 12 |
10 files changed, 220 insertions, 81 deletions
diff --git a/CWRU/CWRU.chlog b/CWRU/CWRU.chlog index a2995298..0a2f63f3 100644 --- a/CWRU/CWRU.chlog +++ b/CWRU/CWRU.chlog @@ -8205,3 +8205,24 @@ subst.c array assignments that are arguments to builtins like `declare', deferring the expansion until the assignment statement is processed. Fixes inconsistency reported by agriffis@n01se.net + + 7/16 + ---- +bashline.c + - fix bash_execute_unix_command to set rl_point correctly based on + READLINE_POINT. The old method of using save_point will not + work because maybe_make_readline_line will change rl_point. Bug + reported by Henning Bekel <h.bekel@googlemail.com> + +trap.c + - fix _run_trap_internal and run_pending_traps to save and restore + value of subst_assign_varlist so the dispose_words on it doesn't + leave dangling pointers after the trap handler runs. Fixes bug + reported by Marc Herbert <marc.herbert@gmail.com> + + 7/22 + ---- +subst.c + - fix off-by-one error in pos_params when computing positional + parameters beginning with index 0. Bug and fix from Isaac Good + <isaacgood@gmail.com> diff --git a/CWRU/CWRU.chlog~ b/CWRU/CWRU.chlog~ index 9b75bc0f..d58971ea 100644 --- a/CWRU/CWRU.chlog~ +++ b/CWRU/CWRU.chlog~ @@ -8197,3 +8197,32 @@ builtins/command.def verbose-handling section, so command -v and command -V honor the PATH set by command -p. Bug and fix from ohki@gssm.otsuka.tsukuba.ac.jp + + 7/9 + --- +subst.c + - change brace_expand_word_list to defer brace expansion on compound + array assignments that are arguments to builtins like `declare', + deferring the expansion until the assignment statement is processed. + Fixes inconsistency reported by agriffis@n01se.net + + 7/16 + ---- +bashline.c + - fix bash_execute_unix_command to set rl_point correctly based on + READLINE_POINT. The old method of using save_point will not + work because maybe_make_readline_line will change rl_point. Bug + reported by Henning Bekel <h.bekel@googlemail.com> + +trap.c + - fix _run_trap_internal and run_pending_traps to save and restore + value of subst_assign_varlist so the dispose_words on it doesn't + leave dangling pointers after the trap handler runs. Fixes bug + reported by Marc Herbert <marc.herbert@gmail.com> + + 7/22 + ---- +subst.c + - fix off-by-one error in pos_params when computing positional + parameters beginning with 0. Bug and fix from Isaac Good + <isaacgood@gmail.com> @@ -3388,7 +3388,6 @@ bash_execute_unix_command (count, key) Keymap xkmap; /* unix command executing keymap */ register int i; intmax_t mi; - int save_point; sh_parser_state_t ps; char *cmd, *value, *l; SHELL_VAR *v; @@ -3432,7 +3431,6 @@ bash_execute_unix_command (count, key) if (v) VSETATTR (v, att_exported); l = value_cell (v); - save_point = rl_point; value = inttostr (rl_point, ibuf, sizeof (ibuf)); v = bind_int_variable ("READLINE_POINT", value); if (v) @@ -3450,7 +3448,7 @@ bash_execute_unix_command (count, key) if (v && legal_number (value_cell (v), &mi)) { i = mi; - if (i != save_point) + if (i != rl_point) { rl_point = i; if (rl_point > rl_end) diff --git a/bashline.c~ b/bashline.c~ index 307c6ea6..bff8e5c2 100644 --- a/bashline.c~ +++ b/bashline.c~ @@ -1386,7 +1386,7 @@ bash_default_completion (text, start, end, qc, compflags) /* If the word starts in `~', and there is no slash in the word, then try completing this word as a username. */ - if (!matches && *text == '~' && !xstrchr (text, '/')) + if (matches ==0 && *text == '~' && mbschr (text, '/') == 0) matches = rl_completion_matches (text, rl_username_completion_function); /* Another one. Why not? If the word starts in '@', then look through @@ -2666,11 +2666,11 @@ bash_directory_completion_hook (dirname) return_value = should_expand_dirname = 0; local_dirname = *dirname; - if (xstrchr (local_dirname, '$')) + if (mbschr (local_dirname, '$')) should_expand_dirname = 1; else { - t = xstrchr (local_dirname, '`'); + t = mbschr (local_dirname, '`'); if (t && unclosed_pair (local_dirname, strlen (local_dirname), "`") == 0) should_expand_dirname = 1; } @@ -3271,7 +3271,7 @@ quote_word_break_chars (text) } /* OK, we have an unquoted character. Check its presence in rl_completer_word_break_characters. */ - if (xstrchr (rl_completer_word_break_characters, *s)) + if (mbschr (rl_completer_word_break_characters, *s)) *r++ = '\\'; /* XXX -- check for standalone tildes here and backslash-quote them */ if (s == text && *s == '~' && file_exists (text)) @@ -3313,7 +3313,7 @@ bash_quote_filename (s, rtype, qcp) the word being completed contains newlines, since those are not quoted correctly using backslashes (a backslash-newline pair is special to the shell parser). */ - if (*qcp == '\0' && cs == COMPLETE_BSQUOTE && xstrchr (s, '\n')) + if (*qcp == '\0' && cs == COMPLETE_BSQUOTE && mbschr (s, '\n')) cs = COMPLETE_SQUOTE; else if (*qcp == '"') cs = COMPLETE_DQUOTE; @@ -3321,11 +3321,11 @@ bash_quote_filename (s, rtype, qcp) cs = COMPLETE_SQUOTE; #if defined (BANG_HISTORY) else if (*qcp == '\0' && history_expansion && cs == COMPLETE_DQUOTE && - history_expansion_inhibited == 0 && xstrchr (s, '!')) + history_expansion_inhibited == 0 && mbschr (s, '!')) cs = COMPLETE_BSQUOTE; if (*qcp == '"' && history_expansion && cs == COMPLETE_DQUOTE && - history_expansion_inhibited == 0 && xstrchr (s, '!')) + history_expansion_inhibited == 0 && mbschr (s, '!')) { cs = COMPLETE_BSQUOTE; *qcp = '\0'; @@ -3450,7 +3450,7 @@ bash_execute_unix_command (count, key) if (v && legal_number (value_cell (v), &mi)) { i = mi; - if (i != save_point) + if (i != rl_point) { rl_point = i; if (rl_point > rl_end) @@ -1,59 +1,130 @@ -*** ../bash-4.0-patched/lib/readline/display.c 2009-01-04 14:32:32.000000000 -0500 ---- lib/readline/display.c 2009-04-25 21:42:18.000000000 -0400 +*** ../bash-4.0-patched/variables.c 2009-01-04 14:32:46.000000000 -0500 +--- variables.c 2009-06-29 09:17:20.000000000 -0400 *************** -*** 513,516 **** ---- 513,517 ---- - data structures. */ - _rl_block_sigint (); -+ RL_SETSTATE (RL_STATE_REDISPLAYING); +*** 222,228 **** +--- 222,230 ---- + static SHELL_VAR *get_hashcmd __P((SHELL_VAR *)); + static SHELL_VAR *assign_hashcmd __P((SHELL_VAR *, char *, arrayind_t, char *)); ++ # if defined (ALIAS) + static SHELL_VAR *build_aliasvar __P((SHELL_VAR *)); + static SHELL_VAR *get_aliasvar __P((SHELL_VAR *)); + static SHELL_VAR *assign_aliasvar __P((SHELL_VAR *, char *, arrayind_t, char *)); ++ # endif + #endif - if (!rl_display_prompt) *************** -*** 1237,1240 **** ---- 1238,1242 ---- - } - -+ RL_UNSETSTATE (RL_STATE_REDISPLAYING); - _rl_release_sigint (); - } +*** 253,256 **** +--- 255,259 ---- + static int visible_var __P((SHELL_VAR *)); + static int visible_and_exported __P((SHELL_VAR *)); ++ static int export_environment_candidate __P((SHELL_VAR *)); + static int local_and_exported __P((SHELL_VAR *)); + static int variable_in_context __P((SHELL_VAR *)); *************** -*** 1773,1777 **** - adjust col_lendiff based on the difference between _rl_last_c_pos - and _rl_screenwidth */ -! if (col_lendiff && (_rl_last_c_pos < _rl_screenwidth)) +*** 376,383 **** + # endif #endif - { ---- 1775,1779 ---- - adjust col_lendiff based on the difference between _rl_last_c_pos - and _rl_screenwidth */ -! if (col_lendiff && ((MB_CUR_MAX == 1 || rl_byte_oriented) || (_rl_last_c_pos < _rl_screenwidth))) + else if (legal_identifier (name)) + { + temp_var = bind_variable (name, string, 0); +! VSETATTR (temp_var, (att_exported | att_imported)); + array_needs_making = 1; + } +--- 379,393 ---- + # endif #endif - { ++ #if 0 + else if (legal_identifier (name)) ++ #else ++ else ++ #endif + { + temp_var = bind_variable (name, string, 0); +! if (legal_identifier (name)) +! VSETATTR (temp_var, (att_exported | att_imported)); +! else +! VSETATTR (temp_var, (att_exported | att_imported | att_invisible)); + array_needs_making = 1; + } *************** -*** 1893,1896 **** ---- 1895,1902 ---- - woff = WRAP_OFFSET (_rl_last_v_pos, wrap_offset); - cpos = _rl_last_c_pos; +*** 868,872 **** + av = array_cell (vv); + strcpy (d, dist_version); +! s = xstrchr (d, '.'); + if (s) + *s++ = '\0'; +--- 878,882 ---- + av = array_cell (vv); + strcpy (d, dist_version); +! s = strchr (d, '.'); + if (s) + *s++ = '\0'; +*************** +*** 1549,1552 **** +--- 1559,1563 ---- + } + ++ #if defined (ALIAS) + static SHELL_VAR * + build_aliasvar (self) +*************** +*** 1601,1604 **** +--- 1612,1617 ---- + return (build_aliasvar (self)); + } ++ #endif /* ALIAS */ + -+ if (cpos == 0 && cpos == new) -+ return; + #endif /* ARRAY_VARS */ + +*************** +*** 1696,1700 **** +--- 1709,1715 ---- + + v = init_dynamic_assoc_var ("BASH_CMDS", get_hashcmd, assign_hashcmd, att_nofree); ++ # if defined (ALIAS) + v = init_dynamic_assoc_var ("BASH_ALIASES", get_aliasvar, assign_aliasvar, att_nofree); ++ # endif + #endif + +*************** +*** 3083,3086 **** +--- 3098,3111 ---- + } + ++ /* Candidate variables for the export environment are either valid variables ++ with the export attribute or invalid variables inherited from the initial ++ environment and simply passed through. */ ++ static int ++ export_environment_candidate (var) ++ SHELL_VAR *var; ++ { ++ return (exported_p (var) && (invisible_p (var) == 0 || imported_p (var))); ++ } + - #if defined (HANDLE_MULTIBYTE) - /* If we have multibyte characters, NEW is indexed by the buffer point in -*************** -*** 1906,1912 **** - desired display position. */ - if ((new > prompt_last_invisible) || /* XXX - don't use woff here */ -! (prompt_physical_chars > _rl_screenwidth && - _rl_last_v_pos == prompt_last_screen_line && -! wrap_offset >= woff && - new > (prompt_last_invisible-(_rl_screenwidth*_rl_last_v_pos)-wrap_offset))) - /* XXX last comparison might need to be >= */ ---- 1912,1918 ---- - desired display position. */ - if ((new > prompt_last_invisible) || /* XXX - don't use woff here */ -! (prompt_physical_chars >= _rl_screenwidth && - _rl_last_v_pos == prompt_last_screen_line && -! wrap_offset >= woff && dpos >= woff && - new > (prompt_last_invisible-(_rl_screenwidth*_rl_last_v_pos)-wrap_offset))) - /* XXX last comparison might need to be >= */ + /* Return non-zero if VAR is a local variable in the current context and + is exported. */ +*************** +*** 3439,3443 **** +--- 3464,3472 ---- + SHELL_VAR **vars; + ++ #if 0 + vars = map_over (visible_and_exported, vcxt); ++ #else ++ vars = map_over (export_environment_candidate, vcxt); ++ #endif + + if (vars == 0) +*************** +*** 3588,3592 **** + export_env[export_env_index = 0] = (char *)NULL; + +! /* Make a dummy variable context from the temporary_env, stick it on + the front of shell_variables, call make_var_export_array on the + whole thing to flatten it, and convert the list of SHELL_VAR *s +--- 3617,3621 ---- + export_env[export_env_index = 0] = (char *)NULL; + +! /* Make a dummy variable context from the temporary_env, stick it on + the front of shell_variables, call make_var_export_array on the + whole thing to flatten it, and convert the list of SHELL_VAR *s diff --git a/lib/readline/readline.c b/lib/readline/readline.c index 3550b354..270eed23 100644 --- a/lib/readline/readline.c +++ b/lib/readline/readline.c @@ -895,7 +895,7 @@ _rl_subseq_result (r, map, key, got_subseq) Keymap m; int type, nt; rl_command_func_t *func, *nf; - + if (r == -2) /* We didn't match anything, and the keymap we're indexed into shadowed a function previously bound to that prefix. Call @@ -134,8 +134,16 @@ size_t ifs_firstc_len; unsigned char ifs_firstc; #endif +/* Sentinel to tell when we are performing variable assignments preceding a + command name and putting them into the environment. Used to make sure + we use the temporary environment when looking up variable values. */ int assigning_in_environment; +/* Used to hold a list of variable assignments preceding a command. Global + so the SIGCHLD handler in jobs.c can unwind-protect it when it runs a + SIGCHLD trap and so it can be saved and restored by the trap handlers. */ +WORD_LIST *subst_assign_varlist = (WORD_LIST *)NULL; + /* Extern functions and variables from different files. */ extern int last_command_exit_value, last_command_exit_signal; extern int subshell_environment; @@ -183,11 +191,6 @@ static int no_longjmp_on_fatal_error = 0; $* on $IFS, primarily when doing assignment statements. */ static int expand_no_split_dollar_star = 0; -/* Used to hold a list of variable assignments preceding a command. Global - so the SIGCHLD handler in jobs.c can unwind-protect it when it runs a - SIGCHLD trap. */ -WORD_LIST *subst_assign_varlist = (WORD_LIST *)NULL; - /* A WORD_LIST of words to be expanded by expand_word_list_internal, without any leading variable assignments. */ static WORD_LIST *garglist = (WORD_LIST *)NULL; @@ -2739,7 +2742,7 @@ pos_params (string, start, end, quoted) save = params = t; } - for (i = 1; params && i < start; i++) + for (i = start ? 1 : 0; params && i < start; i++) params = params->next; if (params == 0) return ((char *)NULL); @@ -8327,7 +8330,7 @@ separate_out_assignments (tlist) { register WORD_LIST *vp, *lp; - if (!tlist) + if (tlist == 0) return ((WORD_LIST *)NULL); if (subst_assign_varlist) @@ -134,8 +134,16 @@ size_t ifs_firstc_len; unsigned char ifs_firstc; #endif +/* Sentinel to tell when we are performing variable assignments preceding a + command name and putting them into the environment. Used to make sure + we use the temporary environment when looking up variable values. */ int assigning_in_environment; +/* Used to hold a list of variable assignments preceding a command. Global + so the SIGCHLD handler in jobs.c can unwind-protect it when it runs a + SIGCHLD trap and so it can be saved and restored by the trap handlers. */ +WORD_LIST *subst_assign_varlist = (WORD_LIST *)NULL; + /* Extern functions and variables from different files. */ extern int last_command_exit_value, last_command_exit_signal; extern int subshell_environment; @@ -183,11 +191,6 @@ static int no_longjmp_on_fatal_error = 0; $* on $IFS, primarily when doing assignment statements. */ static int expand_no_split_dollar_star = 0; -/* Used to hold a list of variable assignments preceding a command. Global - so the SIGCHLD handler in jobs.c can unwind-protect it when it runs a - SIGCHLD trap. */ -WORD_LIST *subst_assign_varlist = (WORD_LIST *)NULL; - /* A WORD_LIST of words to be expanded by expand_word_list_internal, without any leading variable assignments. */ static WORD_LIST *garglist = (WORD_LIST *)NULL; @@ -8327,7 +8330,7 @@ separate_out_assignments (tlist) { register WORD_LIST *vp, *lp; - if (!tlist) + if (tlist == 0) return ((WORD_LIST *)NULL); if (subst_assign_varlist) @@ -8581,7 +8584,7 @@ brace_expand_word_list (tlist, eflags) if ((tlist->word->flags & (W_COMPASSIGN|W_ASSIGNARG)) == (W_COMPASSIGN|W_ASSIGNARG)) { -itrace("brace_expand_word_list: %s: W_COMPASSIGN|W_ASSIGNARG", tlist->word->word); +/*itrace("brace_expand_word_list: %s: W_COMPASSIGN|W_ASSIGNARG", tlist->word->word);*/ PREPEND_LIST (tlist, output_list); continue; } @@ -85,6 +85,7 @@ extern sh_builtin_func_t *this_shell_builtin; extern procenv_t wait_intr_buf; extern int return_catch_flag, return_catch_value; extern int subshell_level; +extern WORD_LIST *subst_assign_varlist; /* The list of things to do originally, before we started trapping. */ SigHandler *original_signals[NSIG]; @@ -262,6 +263,7 @@ run_pending_traps () { register int sig; int old_exit_value, *token_state; + WORD_LIST *save_subst_varlist; if (catch_flag == 0) /* simple optimization */ return; @@ -332,9 +334,14 @@ run_pending_traps () else { token_state = save_token_state (); + save_subst_varlist = subst_assign_varlist; + subst_assign_varlist = 0; + parse_and_execute (savestring (trap_list[sig]), "trap", SEVAL_NONINT|SEVAL_NOHIST|SEVAL_RESETLINE); restore_token_state (token_state); free (token_state); + + subst_assign_varlist = save_subst_varlist; } pending_traps[sig] = 0; @@ -728,6 +735,7 @@ _run_trap_internal (sig, tag) int trap_exit_value, *token_state; int save_return_catch_flag, function_code, flags; procenv_t save_return_catch; + WORD_LIST *save_subst_varlist; trap_exit_value = function_code = 0; /* Run the trap only if SIG is trapped and not ignored, and we are not @@ -745,6 +753,8 @@ _run_trap_internal (sig, tag) trap_saved_exit_value = last_command_exit_value; token_state = save_token_state (); + save_subst_varlist = subst_assign_varlist; + subst_assign_varlist = 0; /* If we're in a function, make sure return longjmps come here, too. */ save_return_catch_flag = return_catch_flag; @@ -763,6 +773,8 @@ _run_trap_internal (sig, tag) restore_token_state (token_state); free (token_state); + subst_assign_varlist = save_subst_varlist; + trap_exit_value = last_command_exit_value; last_command_exit_value = trap_saved_exit_value; running_trap = 0; @@ -85,10 +85,7 @@ extern sh_builtin_func_t *this_shell_builtin; extern procenv_t wait_intr_buf; extern int return_catch_flag, return_catch_value; extern int subshell_level; - -#if defined (PGRP_PIPE) -extern int pgrp_pipe[2]; -#endif +extern WORD_LIST *subst_assign_varlist; /* The list of things to do originally, before we started trapping. */ SigHandler *original_signals[NSIG]; @@ -266,6 +263,7 @@ run_pending_traps () { register int sig; int old_exit_value, *token_state; + WORD_LIST *save_subst_varlist; if (catch_flag == 0) /* simple optimization */ return; @@ -336,9 +334,13 @@ run_pending_traps () else { token_state = save_token_state (); +save_subst_varlist = subst_assign_varlist; +subst_assign_varlist = 0; +itrace("run_pending_traps: subst_assign_varlist = NULL"); parse_and_execute (savestring (trap_list[sig]), "trap", SEVAL_NONINT|SEVAL_NOHIST|SEVAL_RESETLINE); restore_token_state (token_state); free (token_state); +subst_assign_varlist = save_subst_varlist; } pending_traps[sig] = 0; @@ -586,7 +588,7 @@ get_original_signal (sig) int sig; { /* If we aren't sure the of the original value, then get it. */ - if (original_signals[sig] == (SigHandler *)IMPOSSIBLE_TRAP_HANDLER) + if (sig > 0 && sig < NSIG && original_signals[sig] == (SigHandler *)IMPOSSIBLE_TRAP_HANDLER) GETORIGSIG (sig); } |