source:
patches/bash-4.2-branch_update-6.patch@
766988f
Last change on this file since 766988f was 31f34c6, checked in by , 12 years ago | |
---|---|
|
|
File size: 53.4 KB |
-
assoc.c
Submitted By: William Harrington (kb0iic at gmail dot com) Date: 11-04-2012 Initial Package Version: 4.2 Origin: Upstream Upstream Status: Applied Description: Contains all upstream patches up to 4.2-039 diff -Naur bash-4.2.orig/assoc.c bash-4.2/assoc.c
old new 77 77 b = hash_search (key, hash, HASH_CREATE); 78 78 if (b == 0) 79 79 return -1; 80 /* If we are overwriting an existing element's value, we're not going to 81 use the key. Nothing in the array assignment code path frees the key 82 string, so we can free it here to avoid a memory leak. */ 83 if (b->key != key) 84 free (key); 80 85 FREE (b->data); 81 86 b->data = value ? savestring (value) : (char *)0; 82 87 return (0); -
bashline.c
diff -Naur bash-4.2.orig/bashline.c bash-4.2/bashline.c
old new 121 121 static int filename_completion_ignore __P((char **)); 122 122 static int bash_push_line __P((void)); 123 123 124 static rl_icppfunc_t *save_directory_hook __P((void)); 125 static void reset_directory_hook __P((rl_icppfunc_t *)); 126 124 127 static void cleanup_expansion_error __P((void)); 125 128 static void maybe_make_readline_line __P((char *)); 126 129 static void set_up_new_line __P((char *)); … … 243 246 /* Perform spelling correction on directory names during word completion */ 244 247 int dircomplete_spelling = 0; 245 248 249 /* Expand directory names during word/filename completion. */ 250 int dircomplete_expand = 0; 251 int dircomplete_expand_relpath = 0; 252 246 253 static char *bash_completer_word_break_characters = " \t\n\"'@><=;|&(:"; 247 254 static char *bash_nohostname_word_break_characters = " \t\n\"'><=;|&(:"; 248 255 /* )) */ 249 256 257 static const char *default_filename_quote_characters = " \t\n\\\"'@<>=;|&()#$`?*[!:{~"; /*}*/ 258 static char *custom_filename_quote_characters = 0; 259 250 260 static rl_hook_func_t *old_rl_startup_hook = (rl_hook_func_t *)NULL; 251 261 252 262 static int dot_in_path = 0; … … 501 511 502 512 /* Tell the completer that we might want to follow symbolic links or 503 513 do other expansion on directory names. */ 504 rl_directory_rewrite_hook = bash_directory_completion_hook;514 set_directory_hook (); 505 515 506 516 rl_filename_rewrite_hook = bash_filename_rewrite_hook; 507 517 … … 529 539 enable_hostname_completion (perform_hostname_completion); 530 540 531 541 /* characters that need to be quoted when appearing in filenames. */ 532 rl_filename_quote_characters = " \t\n\\\"'@<>=;|&()#$`?*[!:{~"; /*}*/542 rl_filename_quote_characters = default_filename_quote_characters; 533 543 534 544 rl_filename_quoting_function = bash_quote_filename; 535 545 rl_filename_dequoting_function = bash_dequote_filename; … … 564 574 tilde_initialize (); 565 575 rl_attempted_completion_function = attempt_shell_completion; 566 576 rl_completion_entry_function = NULL; 567 rl_directory_rewrite_hook = bash_directory_completion_hook;568 577 rl_ignore_some_completions_function = filename_completion_ignore; 578 rl_filename_quote_characters = default_filename_quote_characters; 579 580 set_directory_hook (); 569 581 } 570 582 571 583 /* Contains the line to push into readline. */ … … 1279 1291 matches = (char **)NULL; 1280 1292 rl_ignore_some_completions_function = filename_completion_ignore; 1281 1293 1294 rl_filename_quote_characters = default_filename_quote_characters; 1295 set_directory_hook (); 1296 1282 1297 /* Determine if this could be a command word. It is if it appears at 1283 1298 the start of the line (ignoring preceding whitespace), or if it 1284 1299 appears after a character that separates commands. It cannot be a … … 1591 1606 } 1592 1607 else 1593 1608 { 1609 if (dircomplete_expand && dot_or_dotdot (filename_hint)) 1610 { 1611 dircomplete_expand = 0; 1612 set_directory_hook (); 1613 dircomplete_expand = 1; 1614 } 1594 1615 mapping_over = 4; 1595 1616 goto inner; 1596 1617 } … … 1791 1812 1792 1813 inner: 1793 1814 val = rl_filename_completion_function (filename_hint, istate); 1815 if (mapping_over == 4 && dircomplete_expand) 1816 set_directory_hook (); 1817 1794 1818 istate = 1; 1795 1819 1796 1820 if (val == 0) … … 2693 2717 return conv; 2694 2718 } 2695 2719 2720 /* Functions to save and restore the appropriate directory hook */ 2721 /* This is not static so the shopt code can call it */ 2722 void 2723 set_directory_hook () 2724 { 2725 if (dircomplete_expand) 2726 { 2727 rl_directory_completion_hook = bash_directory_completion_hook; 2728 rl_directory_rewrite_hook = (rl_icppfunc_t *)0; 2729 } 2730 else 2731 { 2732 rl_directory_rewrite_hook = bash_directory_completion_hook; 2733 rl_directory_completion_hook = (rl_icppfunc_t *)0; 2734 } 2735 } 2736 2737 static rl_icppfunc_t * 2738 save_directory_hook () 2739 { 2740 rl_icppfunc_t *ret; 2741 2742 if (dircomplete_expand) 2743 { 2744 ret = rl_directory_completion_hook; 2745 rl_directory_completion_hook = (rl_icppfunc_t *)NULL; 2746 } 2747 else 2748 { 2749 ret = rl_directory_rewrite_hook; 2750 rl_directory_rewrite_hook = (rl_icppfunc_t *)NULL; 2751 } 2752 2753 return ret; 2754 } 2755 2756 static void 2757 restore_directory_hook (hookf) 2758 rl_icppfunc_t *hookf; 2759 { 2760 if (dircomplete_expand) 2761 rl_directory_completion_hook = hookf; 2762 else 2763 rl_directory_rewrite_hook = hookf; 2764 } 2765 2696 2766 /* Handle symbolic link references and other directory name 2697 2767 expansions while hacking completion. This should return 1 if it modifies 2698 2768 the DIRNAME argument, 0 otherwise. It should make sure not to modify … … 2702 2772 char **dirname; 2703 2773 { 2704 2774 char *local_dirname, *new_dirname, *t; 2705 int return_value, should_expand_dirname ;2775 int return_value, should_expand_dirname, nextch, closer; 2706 2776 WORD_LIST *wl; 2707 2777 struct stat sb; 2708 2778 2709 return_value = should_expand_dirname = 0;2779 return_value = should_expand_dirname = nextch = closer = 0; 2710 2780 local_dirname = *dirname; 2711 2781 2712 if (mbschr (local_dirname, '$')) 2713 should_expand_dirname = 1; 2782 if (t = mbschr (local_dirname, '$')) 2783 { 2784 should_expand_dirname = '$'; 2785 nextch = t[1]; 2786 /* Deliberately does not handle the deprecated $[...] arithmetic 2787 expansion syntax */ 2788 if (nextch == '(') 2789 closer = ')'; 2790 else if (nextch == '{') 2791 closer = '}'; 2792 else 2793 nextch = 0; 2794 } 2714 2795 else 2715 2796 { 2716 2797 t = mbschr (local_dirname, '`'); 2717 2798 if (t && unclosed_pair (local_dirname, strlen (local_dirname), "`") == 0) 2718 should_expand_dirname = 1;2799 should_expand_dirname = '`'; 2719 2800 } 2720 2801 2721 2802 #if defined (HAVE_LSTAT) … … 2739 2820 free (new_dirname); 2740 2821 dispose_words (wl); 2741 2822 local_dirname = *dirname; 2823 /* XXX - change rl_filename_quote_characters here based on 2824 should_expand_dirname/nextch/closer. This is the only place 2825 custom_filename_quote_characters is modified. */ 2826 if (rl_filename_quote_characters && *rl_filename_quote_characters) 2827 { 2828 int i, j, c; 2829 i = strlen (default_filename_quote_characters); 2830 custom_filename_quote_characters = xrealloc (custom_filename_quote_characters, i+1); 2831 for (i = j = 0; c = default_filename_quote_characters[i]; i++) 2832 { 2833 if (c == should_expand_dirname || c == nextch || c == closer) 2834 continue; 2835 custom_filename_quote_characters[j++] = c; 2836 } 2837 custom_filename_quote_characters[j] = '\0'; 2838 rl_filename_quote_characters = custom_filename_quote_characters; 2839 } 2742 2840 } 2743 2841 else 2744 2842 { … … 2758 2856 local_dirname = *dirname = new_dirname; 2759 2857 } 2760 2858 2859 /* no_symbolic_links == 0 -> use (default) logical view of the file system. 2860 local_dirname[0] == '.' && local_dirname[1] == '/' means files in the 2861 current directory (./). 2862 local_dirname[0] == '.' && local_dirname[1] == 0 means relative pathnames 2863 in the current directory (e.g., lib/sh). 2864 XXX - should we do spelling correction on these? */ 2865 2866 /* This is test as it was in bash-4.2: skip relative pathnames in current 2867 directory. Change test to 2868 (local_dirname[0] != '.' || (local_dirname[1] && local_dirname[1] != '/')) 2869 if we want to skip paths beginning with ./ also. */ 2761 2870 if (no_symbolic_links == 0 && (local_dirname[0] != '.' || local_dirname[1])) 2762 2871 { 2763 2872 char *temp1, *temp2; 2764 2873 int len1, len2; 2765 2874 2875 /* If we have a relative path 2876 (local_dirname[0] != '/' && local_dirname[0] != '.') 2877 that is canonical after appending it to the current directory, then 2878 temp1 = temp2+'/' 2879 That is, 2880 strcmp (temp1, temp2) == 0 2881 after adding a slash to temp2 below. It should be safe to not 2882 change those. 2883 */ 2766 2884 t = get_working_directory ("symlink-hook"); 2767 2885 temp1 = make_absolute (local_dirname, t); 2768 2886 free (t); … … 2797 2915 temp2[len2 + 1] = '\0'; 2798 2916 } 2799 2917 } 2800 return_value |= STREQ (local_dirname, temp2) == 0; 2918 2919 /* dircomplete_expand_relpath == 0 means we want to leave relative 2920 pathnames that are unchanged by canonicalization alone. 2921 *local_dirname != '/' && *local_dirname != '.' == relative pathname 2922 (consistent with general.c:absolute_pathname()) 2923 temp1 == temp2 (after appending a slash to temp2) means the pathname 2924 is not changed by canonicalization as described above. */ 2925 if (dircomplete_expand_relpath || ((local_dirname[0] != '/' && local_dirname[0] != '.') && STREQ (temp1, temp2) == 0)) 2926 return_value |= STREQ (local_dirname, temp2) == 0; 2801 2927 free (local_dirname); 2802 2928 *dirname = temp2; 2803 2929 free (temp1); … … 3002 3128 3003 3129 orig_func = rl_completion_entry_function; 3004 3130 orig_attempt_func = rl_attempted_completion_function; 3005 orig_dir_func = rl_directory_rewrite_hook;3006 3131 orig_ignore_func = rl_ignore_some_completions_function; 3007 3132 orig_rl_completer_word_break_characters = rl_completer_word_break_characters; 3133 3134 orig_dir_func = save_directory_hook (); 3135 3008 3136 rl_completion_entry_function = rl_filename_completion_function; 3009 3137 rl_attempted_completion_function = (rl_completion_func_t *)NULL; 3010 rl_directory_rewrite_hook = (rl_icppfunc_t *)NULL;3011 3138 rl_ignore_some_completions_function = filename_completion_ignore; 3012 3139 rl_completer_word_break_characters = " \t\n\"\'"; 3013 3140 … … 3015 3142 3016 3143 rl_completion_entry_function = orig_func; 3017 3144 rl_attempted_completion_function = orig_attempt_func; 3018 rl_directory_rewrite_hook = orig_dir_func;3019 3145 rl_ignore_some_completions_function = orig_ignore_func; 3020 3146 rl_completer_word_break_characters = orig_rl_completer_word_break_characters; 3021 3147 3148 restore_directory_hook (orig_dir_func); 3149 3022 3150 return r; 3023 3151 } 3024 3152 -
bashline.h
diff -Naur bash-4.2.orig/bashline.h bash-4.2/bashline.h
old new 33 33 extern void bashline_reinitialize __P((void)); 34 34 extern int bash_re_edit __P((char *)); 35 35 36 extern void bashline_set_event_hook __P((void)); 37 extern void bashline_reset_event_hook __P((void)); 38 36 39 extern int bind_keyseq_to_unix_command __P((char *)); 37 40 38 41 extern char **bash_default_completion __P((const char *, int, int, int, int)); 39 42 43 void set_directory_hook __P((void)); 44 40 45 /* Used by programmable completion code. */ 41 46 extern char *command_word_completion_function __P((const char *, int)); 42 47 extern char *bash_groupname_completion_function __P((const char *, int)); -
builtins/declare.def
diff -Naur bash-4.2.orig/builtins/declare.def bash-4.2/builtins/declare.def
old new 513 513 *subscript_start = '['; /* ] */ 514 514 var = assign_array_element (name, value, 0); /* XXX - not aflags */ 515 515 *subscript_start = '\0'; 516 if (var == 0) /* some kind of assignment error */ 517 { 518 assign_error++; 519 NEXT_VARIABLE (); 520 } 516 521 } 517 522 else if (simple_array_assign) 518 523 { -
builtins/fc.def
diff -Naur bash-4.2.orig/builtins/fc.def bash-4.2/builtins/fc.def
old new 304 304 last_hist = i - rh - hist_last_line_added; 305 305 306 306 /* XXX */ 307 if ( saved_command_line_count > 0 &&i == last_hist && hlist[last_hist] == 0)307 if (i == last_hist && hlist[last_hist] == 0) 308 308 while (last_hist >= 0 && hlist[last_hist] == 0) 309 309 last_hist--; 310 310 if (last_hist < 0) … … 475 475 HIST_ENTRY **hlist; 476 476 { 477 477 int sign, n, clen, rh; 478 register int i, j ;478 register int i, j, last_hist; 479 479 register char *s; 480 480 481 481 sign = 1; … … 495 495 has been enabled (interactive or not) should use it in the last_hist 496 496 calculation as if it were on. */ 497 497 rh = remember_on_history || ((subshell_environment & SUBSHELL_COMSUB) && enable_history_list); 498 i -= rh + hist_last_line_added; 498 last_hist = i - rh - hist_last_line_added; 499 500 if (i == last_hist && hlist[last_hist] == 0) 501 while (last_hist >= 0 && hlist[last_hist] == 0) 502 last_hist--; 503 if (last_hist < 0) 504 return (-1); 505 506 i = last_hist; 499 507 500 508 /* No specification defaults to most recent command. */ 501 509 if (command == NULL) -
builtins/mapfile.def
diff -Naur bash-4.2.orig/builtins/mapfile.def bash-4.2/builtins/mapfile.def
old new 195 195 /* Reset the buffer for bash own stream */ 196 196 interrupt_immediately++; 197 197 for (array_index = origin, line_count = 1; 198 199 array_index++, line_count++)198 zgetline (fd, &line, &line_length, unbuffered_read) != -1; 199 array_index++) 200 200 { 201 /* Have we exceeded # of lines to store? */202 if (line_count_goal != 0 && line_count > line_count_goal)203 break;204 205 201 /* Remove trailing newlines? */ 206 202 if (flags & MAPF_CHOP) 207 203 do_chop (line); … … 217 213 } 218 214 219 215 bind_array_element (entry, array_index, line, 0); 216 217 /* Have we exceeded # of lines to store? */ 218 line_count++; 219 if (line_count_goal != 0 && line_count > line_count_goal) 220 break; 220 221 } 221 222 222 223 xfree (line); -
builtins/printf.def
diff -Naur bash-4.2.orig/builtins/printf.def bash-4.2/builtins/printf.def
old new 255 255 #endif 256 256 { 257 257 vflag = 1; 258 if (vbsize == 0) 259 vbuf = xmalloc (vbsize = 16); 258 260 vblen = 0; 259 261 if (vbuf) 260 262 vbuf[0] = 0; … … 465 467 secs = shell_start_time; /* roughly $SECONDS */ 466 468 else 467 469 secs = arg; 470 #if defined (HAVE_TZSET) 471 sv_tz ("TZ"); /* XXX -- just make sure */ 472 #endif 468 473 tm = localtime (&secs); 469 474 n = strftime (timebuf, sizeof (timebuf), timefmt, tm); 470 475 free (timefmt); -
builtins/read.def
diff -Naur bash-4.2.orig/builtins/read.def bash-4.2/builtins/read.def
old new 642 642 xfree (input_string); 643 643 return EXECUTION_FAILURE; /* readonly or noassign */ 644 644 } 645 if (assoc_p (var)) 646 { 647 builtin_error (_("%s: cannot convert associative to indexed array"), arrayname); 648 xfree (input_string); 649 return EXECUTION_FAILURE; /* existing associative array */ 650 } 645 651 array_flush (array_cell (var)); 646 652 647 653 alist = list_string (input_string, ifs_chars, 0); … … 731 737 xfree (t1); 732 738 } 733 739 else 734 var = bind_read_variable (varname, t );740 var = bind_read_variable (varname, t ? t : ""); 735 741 } 736 742 else 737 743 { … … 785 791 } 786 792 #endif 787 793 788 if (saw_escape )794 if (saw_escape && input_string && *input_string) 789 795 { 790 796 t = dequote_string (input_string); 791 797 var = bind_read_variable (list->word->word, t); 792 798 xfree (t); 793 799 } 794 800 else 795 var = bind_read_variable (list->word->word, input_string );801 var = bind_read_variable (list->word->word, input_string ? input_string : ""); 796 802 797 803 if (var) 798 804 { -
builtins/shopt.def
diff -Naur bash-4.2.orig/builtins/shopt.def bash-4.2/builtins/shopt.def
old new 61 61 #include "common.h" 62 62 #include "bashgetopt.h" 63 63 64 #if defined (READLINE) 65 # include "../bashline.h" 66 #endif 67 64 68 #if defined (HISTORY) 65 69 # include "../bashhist.h" 66 70 #endif … … 94 98 extern int hist_verify, history_reediting, perform_hostname_completion; 95 99 extern int no_empty_command_completion; 96 100 extern int force_fignore; 97 extern int dircomplete_spelling ;101 extern int dircomplete_spelling, dircomplete_expand; 98 102 99 103 extern int enable_hostname_completion __P((int)); 100 104 #endif … … 121 125 static int set_restricted_shell __P((char *, int)); 122 126 #endif 123 127 128 #if defined (READLINE) 129 static int shopt_set_complete_direxpand __P((char *, int)); 130 #endif 131 124 132 static int shopt_login_shell; 125 133 static int shopt_compat31; 126 134 static int shopt_compat32; … … 150 158 { "compat40", &shopt_compat40, set_compatibility_level }, 151 159 { "compat41", &shopt_compat41, set_compatibility_level }, 152 160 #if defined (READLINE) 161 { "direxpand", &dircomplete_expand, shopt_set_complete_direxpand }, 153 162 { "dirspell", &dircomplete_spelling, (shopt_set_func_t *)NULL }, 154 163 #endif 155 164 { "dotglob", &glob_dot_filenames, (shopt_set_func_t *)NULL }, … … 535 544 return 0; 536 545 } 537 546 547 #if defined (READLINE) 548 static int 549 shopt_set_complete_direxpand (option_name, mode) 550 char *option_name; 551 int mode; 552 { 553 set_directory_hook (); 554 return 0; 555 } 556 #endif 557 538 558 #if defined (RESTRICTED_SHELL) 539 559 /* Don't allow the value of restricted_shell to be modified. */ 540 560 -
command.h
diff -Naur bash-4.2.orig/command.h bash-4.2/command.h
old new 97 97 #define W_HASCTLESC 0x200000 /* word contains literal CTLESC characters */ 98 98 #define W_ASSIGNASSOC 0x400000 /* word looks like associative array assignment */ 99 99 #define W_ARRAYIND 0x800000 /* word is an array index being expanded */ 100 #define W_ASSNGLOBAL 0x1000000 /* word is a global assignment to declare (declare/typeset -g) */ 100 101 101 102 /* Possible values for subshell_environment */ 102 103 #define SUBSHELL_ASYNC 0x01 /* subshell caused by `command &' */ -
doc/bash.1
diff -Naur bash-4.2.orig/doc/bash.1 bash-4.2/doc/bash.1
old new 8948 8948 quoted. This is the behavior of posix mode through version 4.1. 8949 8949 The default bash behavior remains as in previous versions. 8950 8950 .TP 8 8951 .B direxpand 8952 If set, 8953 .B bash 8954 replaces directory names with the results of word expansion when performing 8955 filename completion. This changes the contents of the readline editing 8956 buffer. 8957 If not set, 8958 .B bash 8959 attempts to preserve what the user typed. 8960 .TP 8 8951 8961 .B dirspell 8952 8962 If set, 8953 8963 .B bash -
doc/bashref.texi
diff -Naur bash-4.2.orig/doc/bashref.texi bash-4.2/doc/bashref.texi
old new 4535 4535 quoted. This is the behavior of @sc{posix} mode through version 4.1. 4536 4536 The default Bash behavior remains as in previous versions. 4537 4537 4538 @item direxpand 4539 If set, Bash 4540 replaces directory names with the results of word expansion when performing 4541 filename completion. This changes the contents of the readline editing 4542 buffer. 4543 If not set, Bash attempts to preserve what the user typed. 4544 4538 4545 @item dirspell 4539 4546 If set, Bash 4540 4547 attempts spelling correction on directory names during word completion -
error.c
diff -Naur bash-4.2.orig/error.c bash-4.2/error.c
old new 200 200 201 201 va_end (args); 202 202 if (exit_immediately_on_error) 203 exit_shell (1); 203 { 204 if (last_command_exit_value == 0) 205 last_command_exit_value = 1; 206 exit_shell (last_command_exit_value); 207 } 204 208 } 205 209 206 210 void -
execute_cmd.c
diff -Naur bash-4.2.orig/execute_cmd.c bash-4.2/execute_cmd.c
old new 2196 2196 if (ignore_return && cmd) 2197 2197 cmd->flags |= CMD_IGNORE_RETURN; 2198 2198 2199 #if defined (JOB_CONTROL) 2199 2200 lastpipe_flag = 0; 2200 2201 begin_unwind_frame ("lastpipe-exec"); 2201 2202 lstdin = -1; … … 2204 2205 current shell environment. */ 2205 2206 if (lastpipe_opt && job_control == 0 && asynchronous == 0 && pipe_out == NO_PIPE && prev > 0) 2206 2207 { 2207 lstdin = move_to_high_fd (0, 0, 255);2208 lstdin = move_to_high_fd (0, 1, -1); 2208 2209 if (lstdin > 0) 2209 2210 { 2210 2211 do_piping (prev, pipe_out); … … 2215 2216 lastpipe_jid = stop_pipeline (0, (COMMAND *)NULL); /* XXX */ 2216 2217 add_unwind_protect (lastpipe_cleanup, lastpipe_jid); 2217 2218 } 2218 cmd->flags |= CMD_LASTPIPE; 2219 if (cmd) 2220 cmd->flags |= CMD_LASTPIPE; 2219 2221 } 2220 2222 if (prev >= 0) 2221 2223 add_unwind_protect (close, prev); 2224 #endif 2222 2225 2223 2226 exec_result = execute_command_internal (cmd, asynchronous, prev, pipe_out, fds_to_close); 2224 2227 2228 #if defined (JOB_CONTROL) 2225 2229 if (lstdin > 0) 2226 2230 restore_stdin (lstdin); 2231 #endif 2227 2232 2228 2233 if (prev >= 0) 2229 2234 close (prev); … … 2246 2251 unfreeze_jobs_list (); 2247 2252 } 2248 2253 2254 #if defined (JOB_CONTROL) 2249 2255 discard_unwind_frame ("lastpipe-exec"); 2256 #endif 2250 2257 2251 2258 return (exec_result); 2252 2259 } … … 3575 3582 { 3576 3583 WORD_LIST *w; 3577 3584 struct builtin *b; 3578 int assoc ;3585 int assoc, global; 3579 3586 3580 3587 if (words == 0) 3581 3588 return; 3582 3589 3583 3590 b = 0; 3584 assoc = 0;3591 assoc = global = 0; 3585 3592 3586 3593 for (w = words; w; w = w->next) 3587 3594 if (w->word->flags & W_ASSIGNMENT) … … 3598 3605 #if defined (ARRAY_VARS) 3599 3606 if (assoc) 3600 3607 w->word->flags |= W_ASSIGNASSOC; 3608 if (global) 3609 w->word->flags |= W_ASSNGLOBAL; 3601 3610 #endif 3602 3611 } 3603 3612 #if defined (ARRAY_VARS) 3604 3613 /* Note that we saw an associative array option to a builtin that takes 3605 3614 assignment statements. This is a bit of a kludge. */ 3606 else if (w->word->word[0] == '-' && strchr (w->word->word, 'A')) 3615 else if (w->word->word[0] == '-' && (strchr (w->word->word+1, 'A') || strchr (w->word->word+1, 'g'))) 3616 #else 3617 else if (w->word->word[0] == '-' && strchr (w->word->word+1, 'g')) 3618 #endif 3607 3619 { 3608 3620 if (b == 0) 3609 3621 { … … 3613 3625 else if (b && (b->flags & ASSIGNMENT_BUILTIN)) 3614 3626 words->word->flags |= W_ASSNBLTIN; 3615 3627 } 3616 if ( words->word->flags & W_ASSNBLTIN)3628 if ((words->word->flags & W_ASSNBLTIN) && strchr (w->word->word+1, 'A')) 3617 3629 assoc = 1; 3630 if ((words->word->flags & W_ASSNBLTIN) && strchr (w->word->word+1, 'g')) 3631 global = 1; 3618 3632 } 3619 #endif3620 3633 } 3621 3634 3622 3635 /* Return 1 if the file found by searching $PATH for PATHNAME, defaulting -
bash-4.2
diff -Naur bash-4.2.orig/expr.c bash-4.2/expr.c
old new 476 476 477 477 if (special) 478 478 { 479 if ((op == DIV || op == MOD) && value == 0) 480 { 481 if (noeval == 0) 482 evalerror (_("division by 0")); 483 else 484 value = 1; 485 } 486 479 487 switch (op) 480 488 { 481 489 case MUL: 482 490 lvalue *= value; 483 491 break; 484 492 case DIV: 485 if (value == 0)486 evalerror (_("division by 0"));487 493 lvalue /= value; 488 494 break; 489 495 case MOD: 490 if (value == 0)491 evalerror (_("division by 0"));492 496 lvalue %= value; 493 497 break; 494 498 case PLUS: … … 804 808 val2 = exppower (); 805 809 806 810 if (((op == DIV) || (op == MOD)) && (val2 == 0)) 807 evalerror (_("division by 0")); 811 { 812 if (noeval == 0) 813 evalerror (_("division by 0")); 814 else 815 val2 = 1; 816 } 808 817 809 818 if (op == MUL) 810 819 val1 *= val2; … … 1000 1009 arrayind_t ind; 1001 1010 #endif 1002 1011 1012 /*itrace("expr_streval: %s: noeval = %d", tok, noeval);*/ 1013 /* If we are suppressing evaluation, just short-circuit here instead of 1014 going through the rest of the evaluator. */ 1015 if (noeval) 1016 return (0); 1017 1003 1018 /* [[[[[ */ 1004 1019 #if defined (ARRAY_VARS) 1005 1020 v = (e == ']') ? array_variable_part (tok, (char **)0, (int *)0) : find_variable (tok); … … 1173 1188 #endif /* ARRAY_VARS */ 1174 1189 1175 1190 *cp = '\0'; 1191 /* XXX - watch out for pointer aliasing issues here */ 1192 if (curlval.tokstr && curlval.tokstr == tokstr) 1193 init_lvalue (&curlval); 1194 1176 1195 FREE (tokstr); 1177 1196 tokstr = savestring (tp); 1178 1197 *cp = c; -
lib/glob/glob.c
diff -Naur bash-4.2.orig/lib/glob/glob.c bash-4.2/lib/glob/glob.c
old new 200 200 wchar_t *pat_wc, *dn_wc; 201 201 size_t pat_n, dn_n; 202 202 203 pat_wc = dn_wc = (wchar_t *)NULL; 204 203 205 pat_n = xdupmbstowcs (&pat_wc, NULL, pat); 204 dn_n = xdupmbstowcs (&dn_wc, NULL, dname); 206 if (pat_n != (size_t)-1) 207 dn_n = xdupmbstowcs (&dn_wc, NULL, dname); 205 208 206 209 ret = 0; 207 210 if (pat_n != (size_t)-1 && dn_n !=(size_t)-1) … … 221 224 (pat_wc[0] != L'\\' || pat_wc[1] != L'.')) 222 225 ret = 1; 223 226 } 227 else 228 ret = skipname (pat, dname, flags); 224 229 225 230 FREE (pat_wc); 226 231 FREE (dn_wc); … … 266 271 /* Convert the strings into wide characters. */ 267 272 n = xdupmbstowcs (&wpathname, NULL, pathname); 268 273 if (n == (size_t) -1) 269 /* Something wrong. */ 270 return; 274 { 275 /* Something wrong. Fall back to single-byte */ 276 udequote_pathname (pathname); 277 return; 278 } 271 279 orig_wpathname = wpathname; 272 280 273 281 for (i = j = 0; wpathname && wpathname[i]; ) -
lib/glob/gmisc.c
diff -Naur bash-4.2.orig/lib/glob/gmisc.c bash-4.2/lib/glob/gmisc.c
old new 77 77 wchar_t *wpat; 78 78 size_t wmax; 79 79 { 80 wchar_t wc , *wbrack;81 int matlen, t, in_cclass, in_collsym, in_equiv;80 wchar_t wc; 81 int matlen, bracklen, t, in_cclass, in_collsym, in_equiv; 82 82 83 83 if (*wpat == 0) 84 84 return (0); … … 118 118 break; 119 119 case L'[': 120 120 /* scan for ending `]', skipping over embedded [:...:] */ 121 wbrack = wpat;121 bracklen = 1; 122 122 wc = *wpat++; 123 123 do 124 124 { 125 125 if (wc == 0) 126 126 { 127 matlen += wpat - wbrack - 1; /* incremented below */ 128 break; 127 wpat--; /* back up to NUL */ 128 matlen += bracklen; 129 goto bad_bracket; 129 130 } 130 131 else if (wc == L'\\') 131 132 { 132 wc = *wpat++; 133 if (*wpat == 0) 134 break; 133 /* *wpat == backslash-escaped character */ 134 bracklen++; 135 /* If the backslash or backslash-escape ends the string, 136 bail. The ++wpat skips over the backslash escape */ 137 if (*wpat == 0 || *++wpat == 0) 138 { 139 matlen += bracklen; 140 goto bad_bracket; 141 } 135 142 } 136 143 else if (wc == L'[' && *wpat == L':') /* character class */ 137 144 { 138 145 wpat++; 146 bracklen++; 139 147 in_cclass = 1; 140 148 } 141 149 else if (in_cclass && wc == L':' && *wpat == L']') 142 150 { 143 151 wpat++; 152 bracklen++; 144 153 in_cclass = 0; 145 154 } 146 155 else if (wc == L'[' && *wpat == L'.') /* collating symbol */ 147 156 { 148 157 wpat++; 158 bracklen++; 149 159 if (*wpat == L']') /* right bracket can appear as collating symbol */ 150 wpat++; 160 { 161 wpat++; 162 bracklen++; 163 } 151 164 in_collsym = 1; 152 165 } 153 166 else if (in_collsym && wc == L'.' && *wpat == L']') 154 167 { 155 168 wpat++; 169 bracklen++; 156 170 in_collsym = 0; 157 171 } 158 172 else if (wc == L'[' && *wpat == L'=') /* equivalence class */ 159 173 { 160 174 wpat++; 175 bracklen++; 161 176 if (*wpat == L']') /* right bracket can appear as equivalence class */ 162 wpat++; 177 { 178 wpat++; 179 bracklen++; 180 } 163 181 in_equiv = 1; 164 182 } 165 183 else if (in_equiv && wc == L'=' && *wpat == L']') 166 184 { 167 185 wpat++; 186 bracklen++; 168 187 in_equiv = 0; 169 188 } 189 else 190 bracklen++; 170 191 } 171 192 while ((wc = *wpat++) != L']'); 172 193 matlen++; /* bracket expression can only match one char */ 194 bad_bracket: 173 195 break; 174 196 } 175 197 } … … 213 235 char *pat; 214 236 size_t max; 215 237 { 216 char c , *brack;217 int matlen, t, in_cclass, in_collsym, in_equiv;238 char c; 239 int matlen, bracklen, t, in_cclass, in_collsym, in_equiv; 218 240 219 241 if (*pat == 0) 220 242 return (0); … … 254 276 break; 255 277 case '[': 256 278 /* scan for ending `]', skipping over embedded [:...:] */ 257 brack = pat;279 bracklen = 1; 258 280 c = *pat++; 259 281 do 260 282 { 261 283 if (c == 0) 262 284 { 263 matlen += pat - brack - 1; /* incremented below */ 264 break; 285 pat--; /* back up to NUL */ 286 matlen += bracklen; 287 goto bad_bracket; 265 288 } 266 289 else if (c == '\\') 267 290 { 268 c = *pat++; 269 if (*pat == 0) 270 break; 291 /* *pat == backslash-escaped character */ 292 bracklen++; 293 /* If the backslash or backslash-escape ends the string, 294 bail. The ++pat skips over the backslash escape */ 295 if (*pat == 0 || *++pat == 0) 296 { 297 matlen += bracklen; 298 goto bad_bracket; 299 } 271 300 } 272 301 else if (c == '[' && *pat == ':') /* character class */ 273 302 { 274 303 pat++; 304 bracklen++; 275 305 in_cclass = 1; 276 306 } 277 307 else if (in_cclass && c == ':' && *pat == ']') 278 308 { 279 309 pat++; 310 bracklen++; 280 311 in_cclass = 0; 281 312 } 282 313 else if (c == '[' && *pat == '.') /* collating symbol */ 283 314 { 284 315 pat++; 316 bracklen++; 285 317 if (*pat == ']') /* right bracket can appear as collating symbol */ 286 pat++; 318 { 319 pat++; 320 bracklen++; 321 } 287 322 in_collsym = 1; 288 323 } 289 324 else if (in_collsym && c == '.' && *pat == ']') 290 325 { 291 326 pat++; 327 bracklen++; 292 328 in_collsym = 0; 293 329 } 294 330 else if (c == '[' && *pat == '=') /* equivalence class */ 295 331 { 296 332 pat++; 333 bracklen++; 297 334 if (*pat == ']') /* right bracket can appear as equivalence class */ 298 pat++; 335 { 336 pat++; 337 bracklen++; 338 } 299 339 in_equiv = 1; 300 340 } 301 341 else if (in_equiv && c == '=' && *pat == ']') 302 342 { 303 343 pat++; 344 bracklen++; 304 345 in_equiv = 0; 305 346 } 347 else 348 bracklen++; 306 349 } 307 350 while ((c = *pat++) != ']'); 308 351 matlen++; /* bracket expression can only match one char */ 352 bad_bracket: 309 353 break; 310 354 } 311 355 } -
lib/glob/xmbsrtowcs.c
diff -Naur bash-4.2.orig/lib/glob/xmbsrtowcs.c bash-4.2/lib/glob/xmbsrtowcs.c
old new 35 35 36 36 #if HANDLE_MULTIBYTE 37 37 38 #define WSBUF_INC 32 39 38 40 #ifndef FREE 39 41 # define FREE(x) do { if (x) free (x); } while (0) 40 42 #endif … … 148 150 size_t wsbuf_size; /* Size of WSBUF */ 149 151 size_t wcnum; /* Number of wide characters in WSBUF */ 150 152 mbstate_t state; /* Conversion State */ 151 size_t wcslength; /* Number of wide characters produced by the conversion. */153 size_t n, wcslength; /* Number of wide characters produced by the conversion. */ 152 154 const char *end_or_backslash; 153 155 size_t nms; /* Number of multibyte characters to convert at one time. */ 154 156 mbstate_t tmp_state; … … 171 173 /* Compute the number of produced wide-characters. */ 172 174 tmp_p = p; 173 175 tmp_state = state; 174 wcslength = mbsnrtowcs(NULL, &tmp_p, nms, 0, &tmp_state); 176 177 if (nms == 0 && *p == '\\') /* special initial case */ 178 nms = wcslength = 1; 179 else 180 wcslength = mbsnrtowcs (NULL, &tmp_p, nms, 0, &tmp_state); 181 182 if (wcslength == 0) 183 { 184 tmp_p = p; /* will need below */ 185 tmp_state = state; 186 wcslength = 1; /* take a single byte */ 187 } 175 188 176 189 /* Conversion failed. */ 177 190 if (wcslength == (size_t)-1) … … 186 199 { 187 200 wchar_t *wstmp; 188 201 189 wsbuf_size = wcnum+wcslength+1; /* 1 for the L'\0' or the potential L'\\' */ 202 while (wsbuf_size < wcnum+wcslength+1) /* 1 for the L'\0' or the potential L'\\' */ 203 wsbuf_size += WSBUF_INC; 190 204 191 205 wstmp = (wchar_t *) realloc (wsbuf, wsbuf_size * sizeof (wchar_t)); 192 206 if (wstmp == NULL) … … 199 213 } 200 214 201 215 /* Perform the conversion. This is assumed to return 'wcslength'. 202 *It may set 'p' to NULL. */203 mbsnrtowcs(wsbuf+wcnum, &p, nms, wsbuf_size-wcnum, &state);216 It may set 'p' to NULL. */ 217 n = mbsnrtowcs(wsbuf+wcnum, &p, nms, wsbuf_size-wcnum, &state); 204 218 205 wcnum += wcslength; 219 /* Compensate for taking single byte on wcs conversion failure above. */ 220 if (wcslength == 1 && (n == 0 || n == (size_t)-1)) 221 { 222 state = tmp_state; 223 p = tmp_p; 224 wsbuf[wcnum++] = *p++; 225 } 226 else 227 wcnum += wcslength; 206 228 207 229 if (mbsinit (&state) && (p != NULL) && (*p == '\\')) 208 230 { … … 230 252 If conversion is failed, the return value is (size_t)-1 and the values 231 253 of DESTP and INDICESP are NULL. */ 232 254 233 #define WSBUF_INC 32234 235 255 size_t 236 256 xdupmbstowcs (destp, indicesp, src) 237 257 wchar_t **destp; /* Store the pointer to the wide character string */ -
lib/readline/callback.c
diff -Naur bash-4.2.orig/lib/readline/callback.c bash-4.2/lib/readline/callback.c
old new 148 148 eof = _rl_vi_domove_callback (_rl_vimvcxt); 149 149 /* Should handle everything, including cleanup, numeric arguments, 150 150 and turning off RL_STATE_VIMOTION */ 151 if (RL_ISSTATE (RL_STATE_NUMERICARG) == 0) 152 _rl_internal_char_cleanup (); 153 151 154 return; 152 155 } 153 156 #endif -
lib/readline/input.c
diff -Naur bash-4.2.orig/lib/readline/input.c bash-4.2/lib/readline/input.c
old new 409 409 int 410 410 rl_read_key () 411 411 { 412 int c ;412 int c, r; 413 413 414 414 rl_key_sequence_length++; 415 415 … … 429 429 { 430 430 while (rl_event_hook) 431 431 { 432 if (rl_gather_tyi () < 0) /* XXX - EIO */ 432 if (rl_get_char (&c) != 0) 433 break; 434 435 if ((r = rl_gather_tyi ()) < 0) /* XXX - EIO */ 433 436 { 434 437 rl_done = 1; 435 438 return ('\n'); 436 439 } 440 else if (r == 1) /* read something */ 441 continue; 442 437 443 RL_CHECK_SIGNALS (); 438 if (rl_get_char (&c) != 0)439 break;440 444 if (rl_done) /* XXX - experimental */ 441 445 return ('\n'); 442 446 (*rl_event_hook) (); -
lib/readline/vi_mode.c
diff -Naur bash-4.2.orig/lib/readline/vi_mode.c bash-4.2/lib/readline/vi_mode.c
old new 1114 1114 rl_beg_of_line (1, c); 1115 1115 _rl_vi_last_motion = c; 1116 1116 RL_UNSETSTATE (RL_STATE_VIMOTION); 1117 return ( 0);1117 return (vidomove_dispatch (m)); 1118 1118 } 1119 1119 #if defined (READLINE_CALLBACKS) 1120 1120 /* XXX - these need to handle rl_universal_argument bindings */ … … 1234 1234 _rl_vimvcxt->motion = '$'; 1235 1235 r = rl_domove_motion_callback (_rl_vimvcxt); 1236 1236 } 1237 else if (vi_redoing )1237 else if (vi_redoing && _rl_vi_last_motion != 'd') /* `dd' is special */ 1238 1238 { 1239 1239 _rl_vimvcxt->motion = _rl_vi_last_motion; 1240 1240 r = rl_domove_motion_callback (_rl_vimvcxt); 1241 1241 } 1242 else if (vi_redoing) /* handle redoing `dd' here */ 1243 { 1244 _rl_vimvcxt->motion = _rl_vi_last_motion; 1245 rl_mark = rl_end; 1246 rl_beg_of_line (1, key); 1247 RL_UNSETSTATE (RL_STATE_VIMOTION); 1248 r = vidomove_dispatch (_rl_vimvcxt); 1249 } 1242 1250 #if defined (READLINE_CALLBACKS) 1243 1251 else if (RL_ISSTATE (RL_STATE_CALLBACK)) 1244 1252 { … … 1316 1324 _rl_vimvcxt->motion = '$'; 1317 1325 r = rl_domove_motion_callback (_rl_vimvcxt); 1318 1326 } 1319 else if (vi_redoing )1327 else if (vi_redoing && _rl_vi_last_motion != 'c') /* `cc' is special */ 1320 1328 { 1321 1329 _rl_vimvcxt->motion = _rl_vi_last_motion; 1322 1330 r = rl_domove_motion_callback (_rl_vimvcxt); 1323 1331 } 1332 else if (vi_redoing) /* handle redoing `cc' here */ 1333 { 1334 _rl_vimvcxt->motion = _rl_vi_last_motion; 1335 rl_mark = rl_end; 1336 rl_beg_of_line (1, key); 1337 RL_UNSETSTATE (RL_STATE_VIMOTION); 1338 r = vidomove_dispatch (_rl_vimvcxt); 1339 } 1324 1340 #if defined (READLINE_CALLBACKS) 1325 1341 else if (RL_ISSTATE (RL_STATE_CALLBACK)) 1326 1342 { … … 1377 1393 _rl_vimvcxt->motion = '$'; 1378 1394 r = rl_domove_motion_callback (_rl_vimvcxt); 1379 1395 } 1396 else if (vi_redoing && _rl_vi_last_motion != 'y') /* `yy' is special */ 1397 { 1398 _rl_vimvcxt->motion = _rl_vi_last_motion; 1399 r = rl_domove_motion_callback (_rl_vimvcxt); 1400 } 1401 else if (vi_redoing) /* handle redoing `yy' here */ 1402 { 1403 _rl_vimvcxt->motion = _rl_vi_last_motion; 1404 rl_mark = rl_end; 1405 rl_beg_of_line (1, key); 1406 RL_UNSETSTATE (RL_STATE_VIMOTION); 1407 r = vidomove_dispatch (_rl_vimvcxt); 1408 } 1380 1409 #if defined (READLINE_CALLBACKS) 1381 1410 else if (RL_ISSTATE (RL_STATE_CALLBACK)) 1382 1411 { -
lib/sh/eaccess.c
diff -Naur bash-4.2.orig/lib/sh/eaccess.c bash-4.2/lib/sh/eaccess.c
old new 82 82 const char *path; 83 83 struct stat *finfo; 84 84 { 85 static char *pbuf = 0; 86 85 87 if (*path == '\0') 86 88 { 87 89 errno = ENOENT; … … 106 108 trailing slash. Make sure /dev/fd/xx really uses DEV_FD_PREFIX/xx. 107 109 On most systems, with the notable exception of linux, this is 108 110 effectively a no-op. */ 109 char pbuf[32];111 pbuf = xrealloc (pbuf, sizeof (DEV_FD_PREFIX) + strlen (path + 8)); 110 112 strcpy (pbuf, DEV_FD_PREFIX); 111 113 strcat (pbuf, path + 8); 112 114 return (stat (pbuf, finfo)); -
lib/sh/zread.c
diff -Naur bash-4.2.orig/lib/sh/zread.c bash-4.2/lib/sh/zread.c
old new 160 160 zsyncfd (fd) 161 161 int fd; 162 162 { 163 off_t off; 164 int r; 163 off_t off, r; 165 164 166 165 off = lused - lind; 167 166 r = 0; 168 167 if (off > 0) 169 168 r = lseek (fd, -off, SEEK_CUR); 170 169 171 if (r >= 0)170 if (r != -1) 172 171 lused = lind = 0; 173 172 } -
parse.y
diff -Naur bash-4.2.orig/parse.y bash-4.2/parse.y
old new 2499 2499 We do this only if it is time to do so. Notice that only here 2500 2500 is the mail alarm reset; nothing takes place in check_mail () 2501 2501 except the checking of mail. Please don't change this. */ 2502 if (prompt_is_ps1 && time_to_check_mail ())2502 if (prompt_is_ps1 && parse_and_execute_level == 0 && time_to_check_mail ()) 2503 2503 { 2504 2504 check_mail (); 2505 2505 reset_mail_timer (); … … 3842 3842 int flags; 3843 3843 { 3844 3844 sh_parser_state_t ps; 3845 sh_input_line_state_t ls; 3845 3846 int orig_ind, nc, sflags; 3846 3847 char *ret, *s, *ep, *ostring; 3847 3848 … … 3849 3850 orig_ind = *indp; 3850 3851 ostring = string; 3851 3852 3853 /*itrace("xparse_dolparen: size = %d shell_input_line = `%s'", shell_input_line_size, shell_input_line);*/ 3852 3854 sflags = SEVAL_NONINT|SEVAL_NOHIST|SEVAL_NOFREE; 3853 3855 if (flags & SX_NOLONGJMP) 3854 3856 sflags |= SEVAL_NOLONGJMP; 3855 3857 save_parser_state (&ps); 3858 save_input_line_state (&ls); 3856 3859 3857 3860 /*(*/ 3858 3861 parser_state |= PST_CMDSUBST|PST_EOFTOKEN; /* allow instant ')' */ /*(*/ … … 3861 3864 3862 3865 restore_parser_state (&ps); 3863 3866 reset_parser (); 3867 /* reset_parser clears shell_input_line and associated variables */ 3868 restore_input_line_state (&ls); 3864 3869 if (interactive) 3865 3870 token_to_read = 0; 3866 3871 … … 4895 4900 return (current_command_line_count == 2 ? "\n" : ""); 4896 4901 } 4897 4902 4903 if (parser_state & PST_COMPASSIGN) 4904 return (" "); 4905 4898 4906 /* First, handle some special cases. */ 4899 4907 /*(*/ 4900 4908 /* If we just read `()', assume it's a function definition, and don't … … 5135 5143 case 'A': 5136 5144 /* Make the current time/date into a string. */ 5137 5145 (void) time (&the_time); 5146 #if defined (HAVE_TZSET) 5147 sv_tz ("TZ"); /* XXX -- just make sure */ 5148 #endif 5138 5149 tm = localtime (&the_time); 5139 5150 5140 5151 if (c == 'd') … … 5905 5916 ps->expand_aliases = expand_aliases; 5906 5917 ps->echo_input_at_read = echo_input_at_read; 5907 5918 5919 ps->token = token; 5920 ps->token_buffer_size = token_buffer_size; 5921 /* Force reallocation on next call to read_token_word */ 5922 token = 0; 5923 token_buffer_size = 0; 5924 5908 5925 return (ps); 5909 5926 } 5910 5927 … … 5946 5963 5947 5964 expand_aliases = ps->expand_aliases; 5948 5965 echo_input_at_read = ps->echo_input_at_read; 5966 5967 FREE (token); 5968 token = ps->token; 5969 token_buffer_size = ps->token_buffer_size; 5970 } 5971 5972 sh_input_line_state_t * 5973 save_input_line_state (ls) 5974 sh_input_line_state_t *ls; 5975 { 5976 if (ls == 0) 5977 ls = (sh_input_line_state_t *)xmalloc (sizeof (sh_input_line_state_t)); 5978 if (ls == 0) 5979 return ((sh_input_line_state_t *)NULL); 5980 5981 ls->input_line = shell_input_line; 5982 ls->input_line_size = shell_input_line_size; 5983 ls->input_line_len = shell_input_line_len; 5984 ls->input_line_index = shell_input_line_index; 5985 5986 /* force reallocation */ 5987 shell_input_line = 0; 5988 shell_input_line_size = shell_input_line_len = shell_input_line_index = 0; 5989 } 5990 5991 void 5992 restore_input_line_state (ls) 5993 sh_input_line_state_t *ls; 5994 { 5995 FREE (shell_input_line); 5996 shell_input_line = ls->input_line; 5997 shell_input_line_size = ls->input_line_size; 5998 shell_input_line_len = ls->input_line_len; 5999 shell_input_line_index = ls->input_line_index; 6000 6001 set_line_mbstate (); 5949 6002 } 5950 6003 5951 6004 /************************************************ -
patchlevel.h
diff -Naur bash-4.2.orig/patchlevel.h bash-4.2/patchlevel.h
old new 25 25 regexp `^#define[ ]*PATCHLEVEL', since that's what support/mkversion.sh 26 26 looks for to find the patch level (for the sccs version string). */ 27 27 28 #define PATCHLEVEL 028 #define PATCHLEVEL 39 29 29 30 30 #endif /* _PATCHLEVEL_H_ */ -
pathexp.c
diff -Naur bash-4.2.orig/pathexp.c bash-4.2/pathexp.c
old new 196 196 { 197 197 if ((qflags & QGLOB_FILENAME) && pathname[i+1] == '/') 198 198 continue; 199 if ( (qflags & QGLOB_REGEXP) && ere_char (pathname[i+1]) == 0)199 if (pathname[i+1] != CTLESC && (qflags & QGLOB_REGEXP) && ere_char (pathname[i+1]) == 0) 200 200 continue; 201 201 temp[j++] = '\\'; 202 202 i++; -
print_cmd.c
diff -Naur bash-4.2.orig/print_cmd.c bash-4.2/print_cmd.c
old new 315 315 cprintf ("( "); 316 316 skip_this_indent++; 317 317 make_command_string_internal (command->value.Subshell->command); 318 PRINT_DEFERRED_HEREDOCS (""); 318 319 cprintf (" )"); 319 320 break; 320 321 … … 592 593 newline ("do\n"); 593 594 indentation += indentation_amount; 594 595 make_command_string_internal (arith_for_command->action); 596 PRINT_DEFERRED_HEREDOCS (""); 595 597 semicolon (); 596 598 indentation -= indentation_amount; 597 599 newline ("done"); … … 653 655 } 654 656 655 657 make_command_string_internal (group_command->command); 658 PRINT_DEFERRED_HEREDOCS (""); 656 659 657 660 if (inside_function_def) 658 661 { -
shell.h
diff -Naur bash-4.2.orig/shell.h bash-4.2/shell.h
old new 136 136 int parser_state; 137 137 int *token_state; 138 138 139 char *token; 140 int token_buffer_size; 141 139 142 /* input line state -- line number saved elsewhere */ 140 143 int input_line_terminator; 141 144 int eof_encountered; … … 166 169 167 170 } sh_parser_state_t; 168 171 172 typedef struct _sh_input_line_state_t { 173 char *input_line; 174 int input_line_index; 175 int input_line_size; 176 int input_line_len; 177 } sh_input_line_state_t; 178 169 179 /* Let's try declaring these here. */ 170 180 extern sh_parser_state_t *save_parser_state __P((sh_parser_state_t *)); 171 181 extern void restore_parser_state __P((sh_parser_state_t *)); 182 183 extern sh_input_line_state_t *save_input_line_state __P((sh_input_line_state_t *)); 184 extern void restore_input_line_state __P((sh_input_line_state_t *)); -
bash-4.2
diff -Naur bash-4.2.orig/sig.c bash-4.2/sig.c
old new 46 46 47 47 #if defined (READLINE) 48 48 # include "bashline.h" 49 # include <readline/readline.h> 49 50 #endif 50 51 51 52 #if defined (HISTORY) … … 62 63 #if defined (HISTORY) 63 64 extern int history_lines_this_session; 64 65 #endif 66 extern int no_line_editing; 65 67 66 68 extern void initialize_siglist (); 67 69 … … 505 507 { 506 508 #if defined (HISTORY) 507 509 /* XXX - will inhibit history file being written */ 508 history_lines_this_session = 0; 510 # if defined (READLINE) 511 if (interactive_shell == 0 || interactive == 0 || (sig != SIGHUP && sig != SIGTERM) || no_line_editing || (RL_ISSTATE (RL_STATE_READCMD) == 0)) 512 # endif 513 history_lines_this_session = 0; 509 514 #endif 510 515 terminate_immediately = 0; 511 516 termsig_handler (sig); -
subst.c
diff -Naur bash-4.2.orig/subst.c bash-4.2/subst.c
old new 366 366 f &= ~W_ASSNBLTIN; 367 367 fprintf (stderr, "W_ASSNBLTIN%s", f ? "|" : ""); 368 368 } 369 if (f & W_ASSNGLOBAL) 370 { 371 f &= ~W_ASSNGLOBAL; 372 fprintf (stderr, "W_ASSNGLOBAL%s", f ? "|" : ""); 373 } 369 374 if (f & W_COMPASSIGN) 370 375 { 371 376 f &= ~W_COMPASSIGN; … … 1379 1384 slen = strlen (string + *sindex) + *sindex; 1380 1385 1381 1386 /* The handling of dolbrace_state needs to agree with the code in parse.y: 1382 parse_matched_pair() */ 1383 dolbrace_state = 0; 1384 if (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) 1385 dolbrace_state = (flags & SX_POSIXEXP) ? DOLBRACE_QUOTE : DOLBRACE_PARAM; 1387 parse_matched_pair(). The different initial value is to handle the 1388 case where this function is called to parse the word in 1389 ${param op word} (SX_WORD). */ 1390 dolbrace_state = (flags & SX_WORD) ? DOLBRACE_WORD : DOLBRACE_PARAM; 1391 if ((quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) && (flags & SX_POSIXEXP)) 1392 dolbrace_state = DOLBRACE_QUOTE; 1386 1393 1387 1394 i = *sindex; 1388 1395 while (c = string[i]) … … 2801 2808 } 2802 2809 else if (assign_list) 2803 2810 { 2804 if ( word->flags & W_ASSIGNARG)2811 if ((word->flags & W_ASSIGNARG) && (word->flags & W_ASSNGLOBAL) == 0) 2805 2812 aflags |= ASS_MKLOCAL; 2806 2813 if (word->flags & W_ASSIGNASSOC) 2807 2814 aflags |= ASS_MKASSOC; … … 3371 3378 if (string == 0 || *string == '\0') 3372 3379 return (WORD_LIST *)NULL; 3373 3380 3374 td.flags = 0;3381 td.flags = W_NOSPLIT2; /* no splitting, remove "" and '' */ 3375 3382 td.word = string; 3376 3383 tresult = call_expand_word_internal (&td, quoted, 1, dollar_at_p, has_dollar_at); 3377 3384 return (tresult); … … 3704 3711 break; 3705 3712 } 3706 3713 else if (string[i] == CTLNUL) 3707 i++; 3714 { 3715 i++; 3716 continue; 3717 } 3708 3718 3709 3719 prev_i = i; 3710 3720 ADVANCE_CHAR (string, slen, i); … … 4156 4166 simple = (wpat[0] != L'\\' && wpat[0] != L'*' && wpat[0] != L'?' && wpat[0] != L'['); 4157 4167 #if defined (EXTENDED_GLOB) 4158 4168 if (extended_glob) 4159 simple |= (wpat[1] != L'(' || (wpat[0] != L'*' && wpat[0] != L'?' && wpat[0] != L'+' && wpat[0] != L'!' && wpat[0] != L'@')); /*)*/4169 simple &= (wpat[1] != L'(' || (wpat[0] != L'*' && wpat[0] != L'?' && wpat[0] != L'+' && wpat[0] != L'!' && wpat[0] != L'@')); /*)*/ 4160 4170 #endif 4161 4171 4162 4172 /* If the pattern doesn't match anywhere in the string, go ahead and … … 4607 4617 if (ifs_firstc == 0) 4608 4618 #endif 4609 4619 word->flags |= W_NOSPLIT; 4620 word->flags |= W_NOSPLIT2; 4610 4621 result = call_expand_word_internal (word, quoted, 0, (int *)NULL, (int *)NULL); 4611 4622 expand_no_split_dollar_star = 0; 4612 4623 … … 5798 5809 is the only expansion that creates more than one word. */ 5799 5810 if (qdollaratp && ((hasdol && quoted) || l->next)) 5800 5811 *qdollaratp = 1; 5812 /* If we have a quoted null result (QUOTED_NULL(temp)) and the word is 5813 a quoted null (l->next == 0 && QUOTED_NULL(l->word->word)), the 5814 flags indicate it (l->word->flags & W_HASQUOTEDNULL), and the 5815 expansion is quoted (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) 5816 (which is more paranoia than anything else), we need to return the 5817 quoted null string and set the flags to indicate it. */ 5818 if (l->next == 0 && (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) && QUOTED_NULL(temp) && QUOTED_NULL(l->word->word) && (l->word->flags & W_HASQUOTEDNULL)) 5819 { 5820 w->flags |= W_HASQUOTEDNULL; 5821 } 5801 5822 dispose_words (l); 5802 5823 } 5803 5824 else if ((quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) && hasdol) … … 7176 7197 { 7177 7198 /* Extract the contents of the ${ ... } expansion 7178 7199 according to the Posix.2 rules. */ 7179 value = extract_dollar_brace_string (string, &sindex, quoted, (c == '%' || c == '#' ) ? SX_POSIXEXP : 0);7200 value = extract_dollar_brace_string (string, &sindex, quoted, (c == '%' || c == '#' || c =='/' || c == '^' || c == ',' || c ==':') ? SX_POSIXEXP|SX_WORD : SX_WORD); 7180 7201 if (string[sindex] == RBRACE) 7181 7202 sindex++; 7182 7203 else … … 7268 7289 default: 7269 7290 case '\0': 7270 7291 bad_substitution: 7292 last_command_exit_value = EXECUTION_FAILURE; 7271 7293 report_error (_("%s: bad substitution"), string ? string : "??"); 7272 7294 FREE (value); 7273 7295 FREE (temp); … … 7900 7922 7901 7923 /* State flags */ 7902 7924 int had_quoted_null; 7903 int has_dollar_at ;7925 int has_dollar_at, temp_has_dollar_at; 7904 7926 int tflag; 7905 7927 int pflags; /* flags passed to param_expand */ 7906 7928 … … 8105 8127 if (expanded_something) 8106 8128 *expanded_something = 1; 8107 8129 8108 has_dollar_at = 0;8130 temp_has_dollar_at = 0; 8109 8131 pflags = (word->flags & W_NOCOMSUB) ? PF_NOCOMSUB : 0; 8110 8132 if (word->flags & W_NOSPLIT2) 8111 8133 pflags |= PF_NOSPLIT2; 8112 8134 tword = param_expand (string, &sindex, quoted, expanded_something, 8113 & has_dollar_at, "ed_dollar_at,8135 &temp_has_dollar_at, "ed_dollar_at, 8114 8136 &had_quoted_null, pflags); 8137 has_dollar_at += temp_has_dollar_at; 8115 8138 8116 8139 if (tword == &expand_wdesc_error || tword == &expand_wdesc_fatal) 8117 8140 { … … 8129 8152 temp = tword->word; 8130 8153 dispose_word_desc (tword); 8131 8154 8155 /* Kill quoted nulls; we will add them back at the end of 8156 expand_word_internal if nothing else in the string */ 8157 if (had_quoted_null && temp && QUOTED_NULL (temp)) 8158 { 8159 FREE (temp); 8160 temp = (char *)NULL; 8161 } 8162 8132 8163 goto add_string; 8133 8164 break; 8134 8165 … … 8244 8275 8245 8276 temp = (char *)NULL; 8246 8277 8247 has_dollar_at = 0;8278 temp_has_dollar_at = 0; /* XXX */ 8248 8279 /* Need to get W_HASQUOTEDNULL flag through this function. */ 8249 list = expand_word_internal (tword, Q_DOUBLE_QUOTES, 0, &has_dollar_at, (int *)NULL); 8280 list = expand_word_internal (tword, Q_DOUBLE_QUOTES, 0, &temp_has_dollar_at, (int *)NULL); 8281 has_dollar_at += temp_has_dollar_at; 8250 8282 8251 8283 if (list == &expand_word_error || list == &expand_word_fatal) 8252 8284 { … … 8533 8565 tword->flags |= W_NOEXPAND; /* XXX */ 8534 8566 if (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) 8535 8567 tword->flags |= W_QUOTED; 8536 if (had_quoted_null )8568 if (had_quoted_null && QUOTED_NULL (istring)) 8537 8569 tword->flags |= W_HASQUOTEDNULL; 8538 8570 list = make_word_list (tword, (WORD_LIST *)NULL); 8539 8571 } … … 8564 8596 tword->flags |= W_NOGLOB; 8565 8597 if (word->flags & W_NOEXPAND) 8566 8598 tword->flags |= W_NOEXPAND; 8567 if (had_quoted_null )8599 if (had_quoted_null && QUOTED_NULL (istring)) 8568 8600 tword->flags |= W_HASQUOTEDNULL; /* XXX */ 8569 8601 list = make_word_list (tword, (WORD_LIST *)NULL); 8570 8602 } -
subst.h
diff -Naur bash-4.2.orig/subst.h bash-4.2/subst.h
old new 56 56 #define SX_NOLONGJMP 0x0040 /* don't longjmp on fatal error */ 57 57 #define SX_ARITHSUB 0x0080 /* extracting $(( ... )) (currently unused) */ 58 58 #define SX_POSIXEXP 0x0100 /* extracting new Posix pattern removal expansions in extract_dollar_brace_string */ 59 #define SX_WORD 0x0200 /* extracting word in ${param op word} */ 59 60 60 61 /* Remove backslashes which are quoting backquotes from STRING. Modifies 61 62 STRING, and returns a pointer to it. */ -
support/shobj-conf
diff -Naur bash-4.2.orig/support/shobj-conf bash-4.2/support/shobj-conf
old new 157 157 ;; 158 158 159 159 # Darwin/MacOS X 160 darwin[89]*|darwin1 0*)160 darwin[89]*|darwin1[012]*) 161 161 SHOBJ_STATUS=supported 162 162 SHLIB_STATUS=supported 163 163 … … 186 186 SHLIB_LIBSUFF='dylib' 187 187 188 188 case "${host_os}" in 189 darwin[789]*|darwin1 0*) SHOBJ_LDFLAGS=''189 darwin[789]*|darwin1[012]*) SHOBJ_LDFLAGS='' 190 190 SHLIB_XLDFLAGS='-dynamiclib -arch_only `/usr/bin/arch` -install_name $(libdir)/$@ -current_version $(SHLIB_MAJOR)$(SHLIB_MINOR) -compatibility_version $(SHLIB_MAJOR) -v' 191 191 ;; 192 192 *) SHOBJ_LDFLAGS='-dynamic' -
tests/shopt.right
diff -Naur bash-4.2.orig/tests/shopt.right bash-4.2/tests/shopt.right
old new 12 12 shopt -u compat32 13 13 shopt -u compat40 14 14 shopt -u compat41 15 shopt -u direxpand 15 16 shopt -u dirspell 16 17 shopt -u dotglob 17 18 shopt -u execfail … … 68 69 shopt -u compat32 69 70 shopt -u compat40 70 71 shopt -u compat41 72 shopt -u direxpand 71 73 shopt -u dirspell 72 74 shopt -u dotglob 73 75 shopt -u execfail … … 101 103 compat32 off 102 104 compat40 off 103 105 compat41 off 106 direxpand off 104 107 dirspell off 105 108 dotglob off 106 109 execfail off -
variables.c
diff -Naur bash-4.2.orig/variables.c bash-4.2/variables.c
old new 3653 3653 return n; 3654 3654 } 3655 3655 3656 int 3657 chkexport (name) 3658 char *name; 3659 { 3660 SHELL_VAR *v; 3661 3662 v = find_variable (name); 3663 if (v && exported_p (v)) 3664 { 3665 array_needs_making = 1; 3666 maybe_make_export_env (); 3667 return 1; 3668 } 3669 return 0; 3670 } 3671 3656 3672 void 3657 3673 maybe_make_export_env () 3658 3674 { … … 4214 4230 { "TEXTDOMAIN", sv_locale }, 4215 4231 { "TEXTDOMAINDIR", sv_locale }, 4216 4232 4217 #if defined (HAVE_TZSET) && defined (PROMPT_STRING_DECODE)4233 #if defined (HAVE_TZSET) 4218 4234 { "TZ", sv_tz }, 4219 4235 #endif 4220 4236 … … 4558 4574 } 4559 4575 #endif /* HISTORY */ 4560 4576 4561 #if defined (HAVE_TZSET) && defined (PROMPT_STRING_DECODE)4577 #if defined (HAVE_TZSET) 4562 4578 void 4563 4579 sv_tz (name) 4564 4580 char *name; 4565 4581 { 4566 tzset (); 4582 if (chkexport (name)) 4583 tzset (); 4567 4584 } 4568 4585 #endif 4569 4586 -
variables.h
diff -Naur bash-4.2.orig/variables.h bash-4.2/variables.h
old new 313 313 314 314 extern void sort_variables __P((SHELL_VAR **)); 315 315 316 extern int chkexport __P((char *)); 316 317 extern void maybe_make_export_env __P((void)); 317 318 extern void update_export_env_inplace __P((char *, int, char *)); 318 319 extern void put_command_name_into_env __P((char *));
Note:
See TracBrowser
for help on using the repository browser.