source:
patches/bash-4.0-branch_update-5.patch@
392a73c
Last change on this file since 392a73c was 140d857, checked in by , 15 years ago | |
---|---|
|
|
File size: 34.2 KB |
-
arrayfunc.c
Submitted By: Jim Gifford (jim at cross-lfs dot org) Date: 05-24-2009 Initial Package Version: 4.0 Origin: Upstream Upstream Status: Applied Description: Contains all upstream patches up to 4.0-024 diff -Naur bash-4.0.orig/arrayfunc.c bash-4.0/arrayfunc.c
old new 604 604 } 605 605 } 606 606 607 /* This function assumes s[i] == '['; returns with s[ret] == ']' if 608 an array subscript is correctly parsed. */ 609 int 610 skipsubscript (s, i) 611 const char *s; 612 int i; 613 { 614 int count, c; 615 #if defined (HANDLE_MULTIBYTE) 616 mbstate_t state, state_bak; 617 size_t slength, mblength; 618 #endif 619 620 #if defined (HANDLE_MULTIBYTE) 621 memset (&state, '\0', sizeof (mbstate_t)); 622 slength = strlen (s + i); 623 #endif 624 625 count = 1; 626 while (count) 627 { 628 /* Advance one (possibly multibyte) character in S starting at I. */ 629 #if defined (HANDLE_MULTIBYTE) 630 if (MB_CUR_MAX > 1) 631 { 632 state_bak = state; 633 mblength = mbrlen (s + i, slength, &state); 634 635 if (MB_INVALIDCH (mblength)) 636 { 637 state = state_bak; 638 i++; 639 slength--; 640 } 641 else if (MB_NULLWCH (mblength)) 642 return i; 643 else 644 { 645 i += mblength; 646 slength -= mblength; 647 } 648 } 649 else 650 #endif 651 ++i; 652 653 c = s[i]; 654 655 if (c == 0) 656 break; 657 else if (c == '[') 658 count++; 659 else if (c == ']') 660 count--; 661 } 662 663 return i; 664 } 607 /* skipsubscript moved to subst.c to use private functions. 2009/02/24. */ 665 608 666 609 /* This function is called with SUB pointing to just after the beginning 667 610 `[' of an array subscript and removes the array element to which SUB -
builtins/declare.def
diff -Naur bash-4.0.orig/builtins/declare.def bash-4.0/builtins/declare.def
old new 295 295 subscript_start = (char *)NULL; 296 296 if (t = strchr (name, '[')) /* ] */ 297 297 { 298 /* If offset != 0 we have already validated any array reference */ 299 if (offset == 0 && valid_array_reference (name) == 0) 300 { 301 sh_invalidid (name); 302 assign_error++; 303 NEXT_VARIABLE (); 304 } 298 305 subscript_start = t; 299 306 *t = '\0'; 300 307 making_array_special = 1; … … 484 491 } 485 492 /* declare -a name[[n]] or declare name[n] makes name an indexed 486 493 array variable. */ 487 else if ((making_array_special || (flags_on & att_array)) && array_p (var) == 0 )494 else if ((making_array_special || (flags_on & att_array)) && array_p (var) == 0 && assoc_p (var) == 0) 488 495 var = convert_var_to_array (var); 489 496 #endif /* ARRAY_VARS */ 490 497 -
builtins/exit.def
diff -Naur bash-4.0.orig/builtins/exit.def bash-4.0/builtins/exit.def
old new 113 113 for (i = stopmsg = 0; i < js.j_jobslots; i++) 114 114 if (jobs[i] && STOPPED (i)) 115 115 stopmsg = JSTOPPED; 116 else if (check_jobs_at_exit && stopmsg == 0 && RUNNING (i))116 else if (check_jobs_at_exit && stopmsg == 0 && jobs[i] && RUNNING (i)) 117 117 stopmsg = JRUNNING; 118 118 119 119 if (stopmsg == JSTOPPED) -
builtins/fc.def
diff -Naur bash-4.0.orig/builtins/fc.def bash-4.0/builtins/fc.def
old new 88 88 extern int current_command_line_count; 89 89 extern int literal_history; 90 90 extern int posixly_correct; 91 extern int subshell_environment, interactive_shell; 91 92 92 93 extern int unlink __P((const char *)); 93 94 … … 172 173 register int i; 173 174 register char *sep; 174 175 int numbering, reverse, listing, execute; 175 int histbeg, histend, last_hist, retval, opt ;176 int histbeg, histend, last_hist, retval, opt, rh; 176 177 FILE *stream; 177 178 REPL *rlist, *rl; 178 179 char *ename, *command, *newcom, *fcedit; … … 275 276 276 277 fprintf (stderr, "%s\n", command); 277 278 fc_replhist (command); /* replace `fc -s' with command */ 279 /* Posix says that the re-executed commands should be entered into the 280 history. */ 278 281 return (parse_and_execute (command, "fc", SEVAL_NOHIST)); 279 282 } 280 283 … … 293 296 line was actually added (HISTIGNORE may have caused it to not be), 294 297 so we check hist_last_line_added. */ 295 298 296 last_hist = i - remember_on_history - hist_last_line_added; 299 /* Even though command substitution through parse_and_execute turns off 300 remember_on_history, command substitution in a shell when set -o history 301 has been enabled (interactive or not) should use it in the last_hist 302 calculation as if it were on. */ 303 rh = remember_on_history || ((subshell_environment & SUBSHELL_COMSUB) && enable_history_list); 304 last_hist = i - rh - hist_last_line_added; 297 305 298 306 if (list) 299 307 { … … 456 464 char *command; 457 465 HIST_ENTRY **hlist; 458 466 { 459 int sign, n, clen ;467 int sign, n, clen, rh; 460 468 register int i, j; 461 469 register char *s; 462 470 … … 472 480 line was actually added (HISTIGNORE may have caused it to not be), 473 481 so we check hist_last_line_added. This needs to agree with the 474 482 calculation of last_hist in fc_builtin above. */ 475 i -= remember_on_history + hist_last_line_added; 483 /* Even though command substitution through parse_and_execute turns off 484 remember_on_history, command substitution in a shell when set -o history 485 has been enabled (interactive or not) should use it in the last_hist 486 calculation as if it were on. */ 487 rh = remember_on_history || ((subshell_environment & SUBSHELL_COMSUB) && enable_history_list); 488 i -= rh + hist_last_line_added; 476 489 477 490 /* No specification defaults to most recent command. */ 478 491 if (command == NULL) -
builtins/read.def
diff -Naur bash-4.0.orig/builtins/read.def bash-4.0/builtins/read.def
old new 369 369 code = setjmp (alrmbuf); 370 370 if (code) 371 371 { 372 #if 0 372 /* Tricky. The top of the unwind-protect stack is the free of 373 input_string. We want to run all the rest and use input_string, 374 so we have to remove it from the stack. */ 375 remove_unwind_protect (); 373 376 run_unwind_frame ("read_builtin"); 374 return (EXECUTION_FAILURE);375 #else376 377 input_string[i] = '\0'; /* make sure it's terminated */ 377 retval = 128+SIGALRM; ;378 retval = 128+SIGALRM; 378 379 goto assign_vars; 379 #endif380 380 } 381 381 old_alrm = set_signal_handler (SIGALRM, sigalrm); 382 382 add_unwind_protect (reset_alarm, (char *)NULL); -
execute_cmd.c
diff -Naur bash-4.0.orig/execute_cmd.c bash-4.0/execute_cmd.c
old new 568 568 569 569 /* Fork a subshell, turn off the subshell bit, turn off job 570 570 control and call execute_command () on the command again. */ 571 line_number_for_err_trap = line_number; 571 572 paren_pid = make_child (savestring (make_command_string (command)), 572 573 asynchronous); 573 574 if (paren_pid == 0) … … 610 611 if (user_subshell && was_error_trap && ignore_return == 0 && invert == 0 && exec_result != EXECUTION_SUCCESS) 611 612 { 612 613 last_command_exit_value = exec_result; 614 save_line_number = line_number; 615 line_number = line_number_for_err_trap; 613 616 run_error_trap (); 617 line_number = save_line_number; 614 618 } 615 619 616 620 if (user_subshell && ignore_return == 0 && invert == 0 && exit_immediately_on_error && exec_result != EXECUTION_SUCCESS) … … 766 770 if (was_error_trap && ignore_return == 0 && invert == 0 && pipe_in == NO_PIPE && pipe_out == NO_PIPE && exec_result != EXECUTION_SUCCESS) 767 771 { 768 772 last_command_exit_value = exec_result; 773 line_number = line_number_for_err_trap; 769 774 run_error_trap (); 775 line_number = save_line_number; 770 776 } 771 777 772 778 if (ignore_return == 0 && invert == 0 && … … 2105 2111 REDIRECT *rp; 2106 2112 COMMAND *tc, *second; 2107 2113 int ignore_return, exec_result, was_error_trap, invert; 2114 volatile int save_line_number; 2108 2115 2109 2116 ignore_return = (command->flags & CMD_IGNORE_RETURN) != 0; 2110 2117 … … 2174 2181 invert = (command->flags & CMD_INVERT_RETURN) != 0; 2175 2182 ignore_return = (command->flags & CMD_IGNORE_RETURN) != 0; 2176 2183 2184 line_number_for_err_trap = line_number; 2177 2185 exec_result = execute_pipeline (command, asynchronous, pipe_in, pipe_out, fds_to_close); 2178 2186 2179 2187 if (was_error_trap && ignore_return == 0 && invert == 0 && exec_result != EXECUTION_SUCCESS) 2180 2188 { 2181 2189 last_command_exit_value = exec_result; 2190 save_line_number = line_number; 2191 line_number = line_number_for_err_trap; 2182 2192 run_error_trap (); 2193 line_number = save_line_number; 2183 2194 } 2184 2195 2185 2196 if (ignore_return == 0 && invert == 0 && exit_immediately_on_error && exec_result != EXECUTION_SUCCESS) … … 2930 2941 retval = execute_command (clauses->action); 2931 2942 } 2932 2943 while ((clauses->flags & CASEPAT_FALLTHROUGH) && (clauses = clauses->next)); 2933 if ( (clauses->flags & CASEPAT_TESTNEXT) == 0)2944 if (clauses == 0 || (clauses->flags & CASEPAT_TESTNEXT) == 0) 2934 2945 EXIT_CASE (); 2935 2946 else 2936 2947 break; -
bash-4.0
diff -Naur bash-4.0.orig/jobs.c bash-4.0/jobs.c
old new 442 442 old_pipeline = the_pipeline; 443 443 the_pipeline = saved_pipeline; 444 444 already_making_children = saved_already_making_children; 445 if (discard )445 if (discard && old_pipeline) 446 446 discard_pipeline (old_pipeline); 447 447 } 448 448 … … 4202 4202 sh_closepipe (pgrp_pipe); 4203 4203 } 4204 4204 4205 void 4206 save_pgrp_pipe (p, clear) 4207 int *p; 4208 int clear; 4209 { 4210 p[0] = pgrp_pipe[0]; 4211 p[1] = pgrp_pipe[1]; 4212 if (clear) 4213 pgrp_pipe[0] = pgrp_pipe[1] = -1; 4214 } 4215 4216 void 4217 restore_pgrp_pipe (p) 4218 int *p; 4219 { 4220 pgrp_pipe[0] = p[0]; 4221 pgrp_pipe[1] = p[1]; 4222 } 4223 4205 4224 #endif /* PGRP_PIPE */ -
bash-4.0
diff -Naur bash-4.0.orig/jobs.h bash-4.0/jobs.h
old new 235 235 extern void init_job_stats __P((void)); 236 236 237 237 extern void close_pgrp_pipe __P((void)); 238 extern void save_pgrp_pipe __P((int *, int)); 239 extern void restore_pgrp_pipe __P((int *)); 238 240 239 241 #if defined (JOB_CONTROL) 240 242 extern int job_control; -
lib/glob/glob.c
diff -Naur bash-4.0.orig/lib/glob/glob.c bash-4.0/lib/glob/glob.c
old new 356 356 *np = 0; 357 357 if (ep) 358 358 *ep = 0; 359 if (r )359 if (r && r != &glob_error_return) 360 360 free (r); 361 361 return (struct globval *)0; 362 362 } … … 665 665 (void) closedir (d); 666 666 } 667 667 668 /* compat: if GX_ALLDIRS, add the passed directory also */ 669 if (add_current) 668 /* compat: if GX_ALLDIRS, add the passed directory also, but don't add an 669 empty directory name. */ 670 if (add_current && (flags & GX_NULLDIR) == 0) 670 671 { 671 672 sdlen = strlen (dir); 672 673 nextname = (char *)malloc (sdlen + 1); … … 678 679 nextlink->name = nextname; 679 680 nextlink->next = lastlink; 680 681 lastlink = nextlink; 681 if (flags & GX_NULLDIR) 682 nextname[0] = '\0'; 683 else 684 bcopy (dir, nextname, sdlen + 1); 682 bcopy (dir, nextname, sdlen + 1); 685 683 ++count; 686 684 } 687 685 } … … 942 940 char **array; 943 941 register unsigned int l; 944 942 945 array = glob_dir_to_array (directories[i], temp_results, flags); 943 /* If we're expanding **, we don't need to glue the directory 944 name to the results; we've already done it in glob_vector */ 945 if ((dflags & GX_ALLDIRS) && filename[0] == '*' && filename[1] == '*' && filename[2] == '\0') 946 array = temp_results; 947 else 948 array = glob_dir_to_array (directories[i], temp_results, flags); 946 949 l = 0; 947 950 while (array[l] != NULL) 948 951 ++l; … … 959 962 result[result_size - 1] = NULL; 960 963 961 964 /* Note that the elements of ARRAY are not freed. */ 962 free ((char *) array); 965 if (array != temp_results) 966 free ((char *) array); 963 967 } 964 968 } 965 969 /* Free the directories. */ -
lib/readline/display.c
diff -Naur bash-4.0.orig/lib/readline/display.c bash-4.0/lib/readline/display.c
old new 512 512 /* Block keyboard interrupts because this function manipulates global 513 513 data structures. */ 514 514 _rl_block_sigint (); 515 RL_SETSTATE (RL_STATE_REDISPLAYING); 515 516 516 517 if (!rl_display_prompt) 517 518 rl_display_prompt = ""; … … 1236 1237 visible_wrap_offset = wrap_offset; 1237 1238 } 1238 1239 1240 RL_UNSETSTATE (RL_STATE_REDISPLAYING); 1239 1241 _rl_release_sigint (); 1240 1242 } 1241 1243 … … 1772 1774 space_to_eol will insert too many spaces. XXX - maybe we should 1773 1775 adjust col_lendiff based on the difference between _rl_last_c_pos 1774 1776 and _rl_screenwidth */ 1775 if (col_lendiff && ( _rl_last_c_pos < _rl_screenwidth))1777 if (col_lendiff && ((MB_CUR_MAX == 1 || rl_byte_oriented) || (_rl_last_c_pos < _rl_screenwidth))) 1776 1778 #endif 1777 1779 { 1778 1780 if (_rl_term_autowrap && current_line < inv_botlin) … … 1892 1894 1893 1895 woff = WRAP_OFFSET (_rl_last_v_pos, wrap_offset); 1894 1896 cpos = _rl_last_c_pos; 1897 1898 if (cpos == 0 && cpos == new) 1899 return; 1900 1895 1901 #if defined (HANDLE_MULTIBYTE) 1896 1902 /* If we have multibyte characters, NEW is indexed by the buffer point in 1897 1903 a multibyte string, but _rl_last_c_pos is the display position. In … … 1905 1911 prompt string, since they're both buffer indices and DPOS is a 1906 1912 desired display position. */ 1907 1913 if ((new > prompt_last_invisible) || /* XXX - don't use woff here */ 1908 (prompt_physical_chars > _rl_screenwidth &&1914 (prompt_physical_chars >= _rl_screenwidth && 1909 1915 _rl_last_v_pos == prompt_last_screen_line && 1910 wrap_offset >= woff && 1916 wrap_offset >= woff && dpos >= woff && 1911 1917 new > (prompt_last_invisible-(_rl_screenwidth*_rl_last_v_pos)-wrap_offset))) 1912 1918 /* XXX last comparison might need to be >= */ 1913 1919 { -
lib/readline/readline.h
diff -Naur bash-4.0.orig/lib/readline/readline.h bash-4.0/lib/readline/readline.h
old new 814 814 #define RL_STATE_VIMOTION 0x100000 /* reading vi motion arg */ 815 815 #define RL_STATE_MULTIKEY 0x200000 /* reading multiple-key command */ 816 816 #define RL_STATE_VICMDONCE 0x400000 /* entered vi command mode at least once */ 817 #define RL_STATE_REDISPLAYING 0x800000 /* updating terminal display */ 817 818 818 #define RL_STATE_DONE 0x 800000 /* done; accepted line */819 #define RL_STATE_DONE 0x1000000 /* done; accepted line */ 819 820 820 821 #define RL_SETSTATE(x) (rl_readline_state |= (x)) 821 822 #define RL_UNSETSTATE(x) (rl_readline_state &= ~(x)) -
lib/readline/terminal.c
diff -Naur bash-4.0.orig/lib/readline/terminal.c bash-4.0/lib/readline/terminal.c
old new 355 355 _rl_get_screen_size (fileno (rl_instream), 1); 356 356 if (CUSTOM_REDISPLAY_FUNC ()) 357 357 rl_forced_update_display (); 358 else 358 else if (RL_ISSTATE(RL_STATE_REDISPLAYING) == 0) 359 359 _rl_redisplay_after_sigwinch (); 360 360 } 361 361 } -
lib/sh/winsize.c
diff -Naur bash-4.0.orig/lib/sh/winsize.c bash-4.0/lib/sh/winsize.c
old new 30 30 31 31 #include <sys/ioctl.h> 32 32 33 #if !defined (STRUCT_WINSIZE_IN_SYS_IOCTL) 34 /* For struct winsize on SCO */ 35 /* sys/ptem.h has winsize but needs mblk_t from sys/stream.h */ 36 # if defined (HAVE_SYS_PTEM_H) && defined (TIOCGWINSZ) && defined (SIGWINCH) 37 # if defined (HAVE_SYS_STREAM_H) 38 # include <sys/stream.h> 39 # endif 33 /* Try to find the definitions of `struct winsize' and TIOGCWINSZ */ 34 35 #if defined (GWINSZ_IN_SYS_IOCTL) && !defined (TIOCGWINSZ) 36 # include <sys/ioctl.h> 37 #endif /* GWINSZ_IN_SYS_IOCTL && !TIOCGWINSZ */ 38 39 #if defined (STRUCT_WINSIZE_IN_TERMIOS) && !defined (STRUCT_WINSIZE_IN_SYS_IOCTL) 40 # include <termios.h> 41 #endif /* STRUCT_WINSIZE_IN_TERMIOS && !STRUCT_WINSIZE_IN_SYS_IOCTL */ 42 43 /* Not in either of the standard places, look around. */ 44 #if !defined (STRUCT_WINSIZE_IN_TERMIOS) && !defined (STRUCT_WINSIZE_IN_SYS_IOCTL) 45 # if defined (HAVE_SYS_STREAM_H) 46 # include <sys/stream.h> 47 # endif /* HAVE_SYS_STREAM_H */ 48 # if defined (HAVE_SYS_PTEM_H) /* SVR4.2, at least, has it here */ 40 49 # include <sys/ptem.h> 41 # endif /* HAVE_SYS_PTEM_H && TIOCGWINSZ && SIGWINCH */ 42 #endif /* !STRUCT_WINSIZE_IN_SYS_IOCTL */ 50 # define _IO_PTEM_H /* work around SVR4.2 1.1.4 bug */ 51 # endif /* HAVE_SYS_PTEM_H */ 52 # if defined (HAVE_SYS_PTE_H) /* ??? */ 53 # include <sys/pte.h> 54 # endif /* HAVE_SYS_PTE_H */ 55 #endif /* !STRUCT_WINSIZE_IN_TERMIOS && !STRUCT_WINSIZE_IN_SYS_IOCTL */ 43 56 44 57 #include <stdio.h> 45 58 -
parse.y
diff -Naur bash-4.0.orig/parse.y bash-4.0/parse.y
old new 1122 1122 REDIRECTEE rd; 1123 1123 REDIRECT *r; 1124 1124 1125 tc = $1 ;1125 tc = $1->type == cm_simple ? (COMMAND *)$1->value.Simple : $1; 1126 1126 rd.dest = 1; 1127 1127 r = make_redirection (2, r_duplicating_output, rd); 1128 1128 if (tc->redirects) … … 1615 1615 { 1616 1616 int *ret; 1617 1617 1618 ret = (int *)xmalloc ( 3* sizeof (int));1618 ret = (int *)xmalloc (4 * sizeof (int)); 1619 1619 ret[0] = last_read_token; 1620 1620 ret[1] = token_before_that; 1621 1621 ret[2] = two_tokens_ago; 1622 ret[3] = current_token; 1622 1623 return ret; 1623 1624 } 1624 1625 … … 1631 1632 last_read_token = ts[0]; 1632 1633 token_before_that = ts[1]; 1633 1634 two_tokens_ago = ts[2]; 1635 current_token = ts[3]; 1634 1636 } 1635 1637 1636 1638 /* … … 1877 1879 prompt_again (); 1878 1880 ret = read_a_line (remove_quoted_newline); 1879 1881 #if defined (HISTORY) 1880 if (re member_on_history && (parser_state & PST_HEREDOC))1882 if (ret && remember_on_history && (parser_state & PST_HEREDOC)) 1881 1883 { 1882 1884 /* To make adding the the here-document body right, we need to rely 1883 1885 on history_delimiting_chars() returning \n for the first line of … … 2668 2670 FREE (word_desc_to_read); 2669 2671 word_desc_to_read = (WORD_DESC *)NULL; 2670 2672 2673 current_token = '\n'; /* XXX */ 2671 2674 last_read_token = '\n'; 2672 2675 token_to_read = '\n'; 2673 2676 } … … 2915 2918 #define P_DQUOTE 0x04 2916 2919 #define P_COMMAND 0x08 /* parsing a command, so look for comments */ 2917 2920 #define P_BACKQUOTE 0x10 /* parsing a backquoted command substitution */ 2921 #define P_ARRAYSUB 0x20 /* parsing a [...] array subscript for assignment */ 2918 2922 2919 2923 /* Lexical state while parsing a grouping construct or $(...). */ 2920 2924 #define LEX_WASDOL 0x001 … … 2927 2931 #define LEX_INHEREDOC 0x080 2928 2932 #define LEX_HEREDELIM 0x100 /* reading here-doc delimiter */ 2929 2933 #define LEX_STRIPDOC 0x200 /* <<- strip tabs from here doc delim */ 2934 #define LEX_INWORD 0x400 2930 2935 2931 2936 #define COMSUB_META(ch) ((ch) == ';' || (ch) == '&' || (ch) == '|') 2932 2937 … … 3129 3134 APPEND_NESTRET (); 3130 3135 FREE (nestret); 3131 3136 } 3137 else if ((flags & P_ARRAYSUB) && (tflags & LEX_WASDOL) && (ch == '(' || ch == '{' || ch == '[')) /* ) } ] */ 3138 goto parse_dollar_word; 3132 3139 } 3133 3140 /* Parse an old-style command substitution within double quotes as a 3134 3141 single word. */ … … 3145 3152 else if MBTEST(open != '`' && (tflags & LEX_WASDOL) && (ch == '(' || ch == '{' || ch == '[')) /* ) } ] */ 3146 3153 /* check for $(), $[], or ${} inside quoted string. */ 3147 3154 { 3155 parse_dollar_word: 3148 3156 if (open == ch) /* undo previous increment */ 3149 3157 count--; 3150 3158 if (ch == '(') /* ) */ … … 3179 3187 int open, close; 3180 3188 int *lenp, flags; 3181 3189 { 3182 int count, ch, peekc, tflags, lex_rwlen, lex_ firstind;3190 int count, ch, peekc, tflags, lex_rwlen, lex_wlen, lex_firstind; 3183 3191 int nestlen, ttranslen, start_lineno; 3184 3192 char *ret, *nestret, *ttrans, *heredelim; 3185 3193 int retind, retsize, rflags, hdlen; … … 3200 3208 retind = 0; 3201 3209 3202 3210 start_lineno = line_number; 3203 lex_rwlen = 0;3211 lex_rwlen = lex_wlen = 0; 3204 3212 3205 3213 heredelim = 0; 3206 3214 lex_firstind = -1; … … 3267 3275 continue; 3268 3276 } 3269 3277 3278 if (tflags & LEX_PASSNEXT) /* last char was backslash */ 3279 { 3280 /*itrace("parse_comsub:%d: lex_passnext -> 0 ch = `%c' (%d)", line_number, ch, __LINE__);*/ 3281 tflags &= ~LEX_PASSNEXT; 3282 if (qc != '\'' && ch == '\n') /* double-quoted \<newline> disappears. */ 3283 { 3284 if (retind > 0) 3285 retind--; /* swallow previously-added backslash */ 3286 continue; 3287 } 3288 3289 RESIZE_MALLOCED_BUFFER (ret, retind, 2, retsize, 64); 3290 if MBTEST(ch == CTLESC || ch == CTLNUL) 3291 ret[retind++] = CTLESC; 3292 ret[retind++] = ch; 3293 continue; 3294 } 3295 3296 /* If this is a shell break character, we are not in a word. If not, 3297 we either start or continue a word. */ 3298 if MBTEST(shellbreak (ch)) 3299 { 3300 tflags &= ~LEX_INWORD; 3301 /*itrace("parse_comsub:%d: lex_inword -> 0 ch = `%c' (%d)", line_number, ch, __LINE__);*/ 3302 } 3303 else 3304 { 3305 if (tflags & LEX_INWORD) 3306 { 3307 lex_wlen++; 3308 /*itrace("parse_comsub:%d: lex_inword == 1 ch = `%c' lex_wlen = %d (%d)", line_number, ch, lex_wlen, __LINE__);*/ 3309 } 3310 else 3311 { 3312 /*itrace("parse_comsub:%d: lex_inword -> 1 ch = `%c' (%d)", line_number, ch, __LINE__);*/ 3313 tflags |= LEX_INWORD; 3314 lex_wlen = 0; 3315 } 3316 } 3317 3270 3318 /* Skip whitespace */ 3271 3319 if MBTEST(shellblank (ch) && lex_rwlen == 0) 3272 3320 { … … 3306 3354 } 3307 3355 3308 3356 /* Meta-characters that can introduce a reserved word. Not perfect yet. */ 3309 if MBTEST((tflags & LEX_RESWDOK) == 0 && (tflags & LEX_CKCASE) && (tflags & LEX_INCOMMENT) == 0 && shellmeta(ch))3357 if MBTEST((tflags & LEX_RESWDOK) == 0 && (tflags & LEX_CKCASE) && (tflags & LEX_INCOMMENT) == 0 && (shellmeta(ch) || ch == '\n')) 3310 3358 { 3311 3359 /* Add this character. */ 3312 3360 RESIZE_MALLOCED_BUFFER (ret, retind, 1, retsize, 64); … … 3364 3412 } 3365 3413 tflags &= ~LEX_RESWDOK; 3366 3414 } 3367 else if (shellbreak (ch) == 0) 3415 else if MBTEST((tflags & LEX_CKCOMMENT) && ch == '#' && (lex_rwlen == 0 || ((tflags & LEX_INWORD) && lex_wlen == 0))) 3416 ; /* don't modify LEX_RESWDOK if we're starting a comment */ 3417 else if MBTEST((tflags & LEX_INCASE) && ch != '\n') 3418 /* If we can read a reserved word and we're in case, we're at the 3419 point where we can read a new pattern list or an esac. We 3420 handle the esac case above. If we read a newline, we want to 3421 leave LEX_RESWDOK alone. If we read anything else, we want to 3422 turn off LEX_RESWDOK, since we're going to read a pattern list. */ 3368 3423 { 3369 tflags &= ~LEX_RESWDOK; 3424 tflags &= ~LEX_RESWDOK; 3425 /*itrace("parse_comsub:%d: lex_incase == 1 found `%c', lex_reswordok -> 0", line_number, ch);*/ 3426 } 3427 else if MBTEST(shellbreak (ch) == 0) 3428 { 3429 tflags &= ~LEX_RESWDOK; 3370 3430 /*itrace("parse_comsub:%d: found `%c', lex_reswordok -> 0", line_number, ch);*/ 3371 3431 } 3372 3432 } … … 3394 3454 } 3395 3455 else 3396 3456 shell_ungetc (peekc); 3397 tflags |= LEX_HEREDELIM; 3398 lex_firstind = -1; 3457 if (peekc != '<') 3458 { 3459 tflags |= LEX_HEREDELIM; 3460 lex_firstind = -1; 3461 } 3399 3462 continue; 3400 3463 } 3401 3464 else 3402 ch = peekc; /* fall through and continue XXX - this skips comments if peekc == '#'*/3465 ch = peekc; /* fall through and continue XXX */ 3403 3466 } 3404 /* Not exactly right yet, should handle shell metacharacters, too. If 3405 any changes are made to this test, make analogous changes to subst.c: 3406 extract_delimited_string(). */ 3407 else if MBTEST((tflags & LEX_CKCOMMENT) && (tflags & LEX_INCOMMENT) == 0 && ch == '#' && (retind == 0 || ret[retind-1] == '\n' || shellblank (ret[retind - 1]))) 3467 else if MBTEST((tflags & LEX_CKCOMMENT) && (tflags & LEX_INCOMMENT) == 0 && ch == '#' && (((tflags & LEX_RESWDOK) && lex_rwlen == 0) || ((tflags & LEX_INWORD) && lex_wlen == 0))) 3468 { 3469 /*itrace("parse_comsub:%d: lex_incomment -> 1 (%d)", line_number, __LINE__);*/ 3408 3470 tflags |= LEX_INCOMMENT; 3471 } 3409 3472 3410 if (tflags & LEX_PASSNEXT) /* last char was backslash */ 3411 { 3412 tflags &= ~LEX_PASSNEXT; 3413 if (qc != '\'' && ch == '\n') /* double-quoted \<newline> disappears. */ 3414 { 3415 if (retind > 0) 3416 retind--; /* swallow previously-added backslash */ 3417 continue; 3418 } 3419 3420 RESIZE_MALLOCED_BUFFER (ret, retind, 2, retsize, 64); 3421 if MBTEST(ch == CTLESC || ch == CTLNUL) 3422 ret[retind++] = CTLESC; 3423 ret[retind++] = ch; 3424 continue; 3425 } 3426 else if MBTEST(ch == CTLESC || ch == CTLNUL) /* special shell escapes */ 3473 if MBTEST(ch == CTLESC || ch == CTLNUL) /* special shell escapes */ 3427 3474 { 3428 3475 RESIZE_MALLOCED_BUFFER (ret, retind, 2, retsize, 64); 3429 3476 ret[retind++] = CTLESC; … … 4248 4295 ((token_index > 0 && assignment_acceptable (last_read_token) && token_is_ident (token, token_index)) || 4249 4296 (token_index == 0 && (parser_state&PST_COMPASSIGN)))) 4250 4297 { 4251 ttok = parse_matched_pair (cd, '[', ']', &ttoklen, 0);4298 ttok = parse_matched_pair (cd, '[', ']', &ttoklen, P_ARRAYSUB); 4252 4299 if (ttok == &matched_pair_error) 4253 4300 return -1; /* Bail immediately. */ 4254 4301 RESIZE_MALLOCED_BUFFER (token, token_index, ttoklen + 2, … … 4449 4496 case '}': /* XXX */ 4450 4497 case AND_AND: 4451 4498 case BANG: 4499 case BAR_AND: 4452 4500 case DO: 4453 4501 case DONE: 4454 4502 case ELIF: -
patchlevel.h
diff -Naur bash-4.0.orig/patchlevel.h bash-4.0/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 24 29 29 30 30 #endif /* _PATCHLEVEL_H_ */ -
pcomplete.c
diff -Naur bash-4.0.orig/pcomplete.c bash-4.0/pcomplete.c
old new 1032 1032 cmdlist = build_arg_list (funcname, text, lwords, cw); 1033 1033 1034 1034 pps = &ps; 1035 save_parser_state (pps); 1035 1036 begin_unwind_frame ("gen-shell-function-matches"); 1036 1037 add_unwind_protect (restore_parser_state, (char *)pps); 1037 1038 add_unwind_protect (dispose_words, (char *)cmdlist); -
bash-4.0
diff -Naur bash-4.0.orig/sig.c bash-4.0/sig.c
old new 448 448 termsig_sighandler (sig) 449 449 int sig; 450 450 { 451 /* If we get called twice with the same signal before handling it, 452 terminate right away. */ 453 if ( 454 #ifdef SIGHUP 455 sig != SIGHUP && 456 #endif 457 #ifdef SIGINT 458 sig != SIGINT && 459 #endif 460 #ifdef SIGDANGER 461 sig != SIGDANGER && 462 #endif 463 #ifdef SIGPIPE 464 sig != SIGPIPE && 465 #endif 466 #ifdef SIGALRM 467 sig != SIGALRM && 468 #endif 469 #ifdef SIGTERM 470 sig != SIGTERM && 471 #endif 472 #ifdef SIGXCPU 473 sig != SIGXCPU && 474 #endif 475 #ifdef SIGXFSZ 476 sig != SIGXFSZ && 477 #endif 478 #ifdef SIGVTALRM 479 sig != SIGVTALRM && 480 #endif 481 #ifdef SIGLOST 482 sig != SIGLOST && 483 #endif 484 #ifdef SIGUSR1 485 sig != SIGUSR1 && 486 #endif 487 #ifdef SIGUSR2 488 sig != SIGUSR2 && 489 #endif 490 sig == terminating_signal) 491 terminate_immediately = 1; 492 451 493 terminating_signal = sig; 452 494 453 495 /* XXX - should this also trigger when interrupt_immediately is set? */ -
subst.c
diff -Naur bash-4.0.orig/subst.c bash-4.0/subst.c
old new 85 85 86 86 /* Flags for the `pflags' argument to param_expand() */ 87 87 #define PF_NOCOMSUB 0x01 /* Do not perform command substitution */ 88 #define PF_IGNUNBOUND 0x02 /* ignore unbound vars even if -u set */ 88 89 89 90 /* These defs make it easier to use the editor. */ 90 91 #define LBRACE '{' … … 222 223 static int skip_double_quoted __P((char *, size_t, int)); 223 224 static char *extract_delimited_string __P((char *, int *, char *, char *, char *, int)); 224 225 static char *extract_dollar_brace_string __P((char *, int *, int, int)); 226 static int skip_matched_pair __P((const char *, int, int, int, int)); 225 227 226 228 static char *pos_params __P((char *, int, int, int)); 227 229 … … 262 264 static int chk_atstar __P((char *, int, int *, int *)); 263 265 static int chk_arithsub __P((const char *, int)); 264 266 265 static WORD_DESC *parameter_brace_expand_word __P((char *, int, int ));267 static WORD_DESC *parameter_brace_expand_word __P((char *, int, int, int)); 266 268 static WORD_DESC *parameter_brace_expand_indir __P((char *, int, int, int *, int *)); 267 269 static WORD_DESC *parameter_brace_expand_rhs __P((char *, char *, int, int, int *, int *)); 268 270 static void parameter_brace_expand_error __P((char *, char *)); … … 1374 1376 1375 1377 #define CQ_RETURN(x) do { no_longjmp_on_fatal_error = 0; return (x); } while (0) 1376 1378 1379 /* This function assumes s[i] == open; returns with s[ret] == close; used to 1380 parse array subscripts. FLAGS currently unused. */ 1381 static int 1382 skip_matched_pair (string, start, open, close, flags) 1383 const char *string; 1384 int start, open, close, flags; 1385 { 1386 int i, pass_next, backq, si, c, count; 1387 size_t slen; 1388 char *temp, *ss; 1389 DECLARE_MBSTATE; 1390 1391 slen = strlen (string + start) + start; 1392 no_longjmp_on_fatal_error = 1; 1393 1394 i = start + 1; /* skip over leading bracket */ 1395 count = 1; 1396 pass_next = backq = 0; 1397 ss = (char *)string; 1398 while (c = string[i]) 1399 { 1400 if (pass_next) 1401 { 1402 pass_next = 0; 1403 if (c == 0) 1404 CQ_RETURN(i); 1405 ADVANCE_CHAR (string, slen, i); 1406 continue; 1407 } 1408 else if (c == '\\') 1409 { 1410 pass_next = 1; 1411 i++; 1412 continue; 1413 } 1414 else if (backq) 1415 { 1416 if (c == '`') 1417 backq = 0; 1418 ADVANCE_CHAR (string, slen, i); 1419 continue; 1420 } 1421 else if (c == '`') 1422 { 1423 backq = 1; 1424 i++; 1425 continue; 1426 } 1427 else if (c == open) 1428 { 1429 count++; 1430 i++; 1431 continue; 1432 } 1433 else if (c == close) 1434 { 1435 count--; 1436 if (count == 0) 1437 break; 1438 i++; 1439 continue; 1440 } 1441 else if (c == '\'' || c == '"') 1442 { 1443 i = (c == '\'') ? skip_single_quoted (ss, slen, ++i) 1444 : skip_double_quoted (ss, slen, ++i); 1445 /* no increment, the skip functions increment past the closing quote. */ 1446 } 1447 else if (c == '$' && (string[i+1] == LPAREN || string[i+1] == LBRACE)) 1448 { 1449 si = i + 2; 1450 if (string[si] == '\0') 1451 CQ_RETURN(si); 1452 1453 if (string[i+1] == LPAREN) 1454 temp = extract_delimited_string (ss, &si, "$(", "(", ")", SX_NOALLOC|SX_COMMAND); /* ) */ 1455 else 1456 temp = extract_dollar_brace_string (ss, &si, 0, SX_NOALLOC); 1457 i = si; 1458 if (string[i] == '\0') /* don't increment i past EOS in loop */ 1459 break; 1460 i++; 1461 continue; 1462 } 1463 else 1464 ADVANCE_CHAR (string, slen, i); 1465 } 1466 1467 CQ_RETURN(i); 1468 } 1469 1470 #if defined (ARRAY_VARS) 1471 int 1472 skipsubscript (string, start) 1473 const char *string; 1474 int start; 1475 { 1476 return (skip_matched_pair (string, start, '[', ']', 0)); 1477 } 1478 #endif 1479 1377 1480 /* Skip characters in STRING until we find a character in DELIMS, and return 1378 1481 the index of that character. START is the index into string at which we 1379 1482 begin. This is similar in spirit to strpbrk, but it returns an index into … … 5093 5196 the shell, e.g., "@", "$", "*", etc. QUOTED, if non-zero, means that 5094 5197 NAME was found inside of a double-quoted expression. */ 5095 5198 static WORD_DESC * 5096 parameter_brace_expand_word (name, var_is_special, quoted )5199 parameter_brace_expand_word (name, var_is_special, quoted, pflags) 5097 5200 char *name; 5098 int var_is_special, quoted ;5201 int var_is_special, quoted, pflags; 5099 5202 { 5100 5203 WORD_DESC *ret; 5101 5204 char *temp, *tt; … … 5127 5230 strcpy (tt + 1, name); 5128 5231 5129 5232 ret = param_expand (tt, &sindex, quoted, (int *)NULL, (int *)NULL, 5130 (int *)NULL, (int *)NULL, 0);5233 (int *)NULL, (int *)NULL, pflags); 5131 5234 free (tt); 5132 5235 } 5133 5236 #if defined (ARRAY_VARS) … … 5188 5291 char *temp, *t; 5189 5292 WORD_DESC *w; 5190 5293 5191 w = parameter_brace_expand_word (name, var_is_special, quoted );5294 w = parameter_brace_expand_word (name, var_is_special, quoted, PF_IGNUNBOUND); 5192 5295 t = w->word; 5193 5296 /* Have to dequote here if necessary */ 5194 5297 if (t) … … 5205 5308 if (t == 0) 5206 5309 return (WORD_DESC *)NULL; 5207 5310 5208 w = parameter_brace_expand_word (t, SPECIAL_VAR(t, 0), quoted );5311 w = parameter_brace_expand_word (t, SPECIAL_VAR(t, 0), quoted, 0); 5209 5312 free (t); 5210 5313 5211 5314 return w; … … 6556 6659 if (want_indir) 6557 6660 tdesc = parameter_brace_expand_indir (name + 1, var_is_special, quoted, quoted_dollar_atp, contains_dollar_at); 6558 6661 else 6559 tdesc = parameter_brace_expand_word (name, var_is_special, quoted );6662 tdesc = parameter_brace_expand_word (name, var_is_special, quoted, PF_IGNUNBOUND); 6560 6663 6561 6664 if (tdesc) 6562 6665 { … … 6887 6990 case '*': /* `$*' */ 6888 6991 list = list_rest_of_args (); 6889 6992 6890 if (list == 0 && unbound_vars_is_error )6993 if (list == 0 && unbound_vars_is_error && (pflags & PF_IGNUNBOUND) == 0) 6891 6994 { 6892 6995 uerror[0] = '$'; 6893 6996 uerror[1] = '*'; … … 6949 7052 case '@': /* `$@' */ 6950 7053 list = list_rest_of_args (); 6951 7054 6952 if (list == 0 && unbound_vars_is_error )7055 if (list == 0 && unbound_vars_is_error && (pflags & PF_IGNUNBOUND) == 0) 6953 7056 { 6954 7057 uerror[0] = '$'; 6955 7058 uerror[1] = '@'; -
bash-4.0
diff -Naur bash-4.0.orig/trap.c bash-4.0/trap.c
old new 755 755 } 756 756 757 757 flags = SEVAL_NONINT|SEVAL_NOHIST; 758 if (sig != DEBUG_TRAP && sig != RETURN_TRAP )758 if (sig != DEBUG_TRAP && sig != RETURN_TRAP && sig != ERROR_TRAP) 759 759 flags |= SEVAL_RESETLINE; 760 760 if (function_code == 0) 761 761 parse_and_execute (trap_command, tag, flags); … … 798 798 run_debug_trap () 799 799 { 800 800 int trap_exit_value; 801 pid_t save_pgrp; 802 int save_pipe[2]; 801 803 802 804 /* XXX - question: should the DEBUG trap inherit the RETURN trap? */ 803 805 trap_exit_value = 0; 804 806 if ((sigmodes[DEBUG_TRAP] & SIG_TRAPPED) && ((sigmodes[DEBUG_TRAP] & SIG_IGNORED) == 0) && ((sigmodes[DEBUG_TRAP] & SIG_INPROGRESS) == 0)) 805 807 { 808 #if defined (JOB_CONTROL) 809 save_pgrp = pipeline_pgrp; 810 pipeline_pgrp = 0; 811 save_pipeline (1); 812 # if defined (PGRP_PIPE) 813 save_pgrp_pipe (save_pipe, 1); 814 # endif 815 stop_making_children (); 816 #endif 817 806 818 trap_exit_value = _run_trap_internal (DEBUG_TRAP, "debug trap"); 819 820 #if defined (JOB_CONTROL) 821 pipeline_pgrp = save_pgrp; 822 restore_pipeline (1); 823 # if defined (PGRP_PIPE) 824 close_pgrp_pipe (); 825 restore_pgrp_pipe (save_pipe); 826 # endif 827 if (pipeline_pgrp > 0) 828 give_terminal_to (pipeline_pgrp, 1); 829 notify_and_cleanup (); 830 #endif 807 831 808 832 #if defined (DEBUGGER) 809 833 /* If we're in the debugger and the DEBUG trap returns 2 while we're in
Note:
See TracBrowser
for help on using the repository browser.