diff --git a/CWRU/CWRU.chlog b/CWRU/CWRU.chlog index be4ffecf..4c6c161b 100644 --- a/CWRU/CWRU.chlog +++ b/CWRU/CWRU.chlog @@ -1,4 +1,4 @@ - 2/14/2011 +' 2/14/2011 --------- [bash-4.2 released] @@ -13905,3 +13905,45 @@ lib/readline/display.c - expand_prompt: use `ret' as first parameter to _rl_find_prev_mbchar since that needs the base of the array. Bug from fuzzing reported by Eduardo Bustamante + + 5/15 + ---- +execute_cmd.c + - execute_simple_command, execute_arith_command, execute_cond_command, + execute_arith_for_command: adjust the line number when executing a + function interactively so that the first command in the function is + line 1, not line 0, as Posix requires. Reported by Robert Elz + + - execute_simple_command, execute_arith_command, execute_cond_command, + execute_arith_for_command: ony adjust the line number when executing + a function interactively if we are not sourcing a file + (sourcelevel == 0), so this is consistent everywhere we adjust the + line number + + 5/16 + ---- +bashline.c + - bash_directory_completion_hook: when calling split_at_delims to see + whether a ${ or $( is closed, use the right value for `start' relative + to the substring beginning at `$'. Bug from fuzzing reported by + Eduardo Bustamante + +expr.c + - expassign: if the call to expcond generates a syntax error in a + context when the shell won't longjmp (like when evaluating $PS1), + it will end up NULL and we need to catch it before calling strlen. + Bug from fuzzing reported by Eduardo Bustamante + +examples/bash-completion/ + - new place to include a current or recent version of the + bash-completion package + + 5/19 + ---- +lib/readline/display.c + - CHECK_INV_LBREAKS: new versions for multibyte and single-byte chars, + so the multibyte version can check and increase the size of + line_state_invisible->wbsize and line_state_invisible->wrapped_line, + callers who call CHECK_INV_LBREAKS must update + wrapped_line[newlines] when in HANDLE_MULTIBYTE mode. Fuzzing bug + reported by Eduardo Bustamante diff --git a/MANIFEST b/MANIFEST index b283adc6..67c9b311 100644 --- a/MANIFEST +++ b/MANIFEST @@ -11,6 +11,7 @@ cross-build d doc d examples d #examples/obashdb d +examples/bash-completion d examples/complete d examples/functions d examples/scripts d @@ -651,8 +652,9 @@ examples/INDEX.html f #examples/obashdb/README f #examples/obashdb/bashdb f #examples/obashdb/bashdb.el f +examples/bash-completion/README f +examples/bash-completion/bash-completion-2.5.tar.xz f examples/complete/bash_completion f -examples/complete/bash-completion-2.5.tar.xz f examples/complete/cdfunc f examples/complete/complete-examples f #examples/complete/complete.ianmac f diff --git a/README b/README index ad87aa8a..66a6cb47 100644 --- a/README +++ b/README @@ -88,6 +88,18 @@ to bash-maintainers@gnu.org. While the Bash maintainers do not promise to fix all bugs, we would like this shell to be the best that we can make it. +Other Packages +============== + +This distribution includes, in examples/bash-completion, a recent version +of the `bash-completion' package, which provides programmable completions +for a number of commands. It's available as a package in many distributions, +and that is the first place from which to obtain it. If it's not a package +from your vendor, you may install the included version. + +The latest version of bash-completion is always available from +https://github.com/scop/bash-completion. + Enjoy! Chet Ramey diff --git a/bashline.c b/bashline.c index 7884416a..c92255d6 100644 --- a/bashline.c +++ b/bashline.c @@ -3247,7 +3247,7 @@ bash_directory_completion_hook (dirname) char delims[2]; delims[0] = closer; delims[1] = 0; - p = skip_to_delim (t, t - local_dirname + 1, delims, SD_NOJMP|SD_COMPLETE); + p = skip_to_delim (t, 1, delims, SD_NOJMP|SD_COMPLETE); if (t[p] != closer) should_expand_dirname = 0; } diff --git a/examples/bash-completion/README b/examples/bash-completion/README new file mode 100644 index 00000000..fb5e7654 --- /dev/null +++ b/examples/bash-completion/README @@ -0,0 +1,7 @@ +Master source: https://github.com/scop/bash-completion + +This is the latest version of the bash-completion package, which provides +programmable completion specifications for a large number of commands. + +If you are a vendor installing bash or preparing a package containing bash, +please install the latest version of bash-completion when installing bash. diff --git a/examples/bash-completion/bash-completion-2.5.tar.xz b/examples/bash-completion/bash-completion-2.5.tar.xz new file mode 100644 index 00000000..f5b90790 Binary files /dev/null and b/examples/bash-completion/bash-completion-2.5.tar.xz differ diff --git a/execute_cmd.c b/execute_cmd.c index 66ecd978..0183a105 100644 --- a/execute_cmd.c +++ b/execute_cmd.c @@ -2974,11 +2974,12 @@ execute_arith_for_command (arith_for_command) line_number before executing each expression -- for $LINENO and the DEBUG trap. */ line_number = arith_lineno = arith_for_command->line; - if (variable_context && interactive_shell) + if (variable_context && interactive_shell && sourcelevel == 0) { - line_number -= function_line_number; - if (line_number < 0) - line_number = 0; + /* line numbers in a function start at 1 */ + line_number -= function_line_number - 1; + if (line_number <= 0) + line_number = 1; } /* Evaluate the initialization expression. */ @@ -3632,11 +3633,12 @@ execute_arith_command (arith_command) this_command_name = "(("; /* )) */ line_number_for_err_trap = line_number = arith_command->line; /* If we're in a function, update the line number information. */ - if (variable_context && interactive_shell) + if (variable_context && interactive_shell && sourcelevel == 0) { - line_number -= function_line_number; - if (line_number < 0) - line_number = 0; + /* line numbers in a function start at 1 */ + line_number -= function_line_number - 1; + if (line_number <= 0) + line_number = 1; } command_string_index = 0; @@ -3833,11 +3835,12 @@ execute_cond_command (cond_command) this_command_name = "[["; line_number_for_err_trap = line_number = cond_command->line; /* If we're in a function, update the line number information. */ - if (variable_context && interactive_shell) + if (variable_context && interactive_shell && sourcelevel == 0) { - line_number -= function_line_number; - if (line_number < 0) - line_number = 0; + /* line numbers in a function start at 1 */ + line_number -= function_line_number - 1; + if (line_number <= 0) + line_number = 1; } command_string_index = 0; print_cond_command (cond_command); @@ -4087,9 +4090,10 @@ execute_simple_command (simple_command, pipe_in, pipe_out, async, fds_to_close) /* If we're in a function, update the line number information. */ if (variable_context && interactive_shell && sourcelevel == 0) { - line_number -= function_line_number; - if (line_number < 0) - line_number = 0; + /* line numbers in a function start at 1 */ + line_number -= function_line_number - 1; + if (line_number <= 0) + line_number = 1; } /* Remember what this command line looks like at invocation. */ diff --git a/expr.c b/expr.c index 1770cc00..fee7a4aa 100644 --- a/expr.c +++ b/expr.c @@ -501,6 +501,9 @@ expassign () lvalue = value; } + if (tokstr == 0) + evalerror (_("syntax error in variable assignment")); + /* XXX - watch out for pointer aliasing issues here */ lhs = savestring (tokstr); /* save ind in case rhs is string var and evaluation overwrites it */ diff --git a/lib/readline/display.c b/lib/readline/display.c index a4a9abd2..35c09490 100644 --- a/lib/readline/display.c +++ b/lib/readline/display.c @@ -764,6 +764,21 @@ rl_redisplay (void) wrap_offset = prompt_invis_chars_first_line = 0; } +#if defined (HANDLE_MULTIBYTE) +#define CHECK_INV_LBREAKS() \ + do { \ + if (newlines >= (inv_lbsize - 2)) \ + { \ + inv_lbsize *= 2; \ + inv_lbreaks = (int *)xrealloc (inv_lbreaks, inv_lbsize * sizeof (int)); \ + } \ + if (newlines >= (line_state_invisible->wbsize - 2)) \ + { \ + line_state_invisible->wbsize *= 2; \ + line_state_invisible->wrapped_line = (int *)xrealloc (line_state_invisible->wrapped_line, line_state_invisible->wbsize * sizeof(int)); \ + } \ + } while (0) +#else #define CHECK_INV_LBREAKS() \ do { \ if (newlines >= (inv_lbsize - 2)) \ @@ -772,6 +787,7 @@ rl_redisplay (void) inv_lbreaks = (int *)xrealloc (inv_lbreaks, inv_lbsize * sizeof (int)); \ } \ } while (0) +#endif /* !HANDLE_MULTIBYTE */ #if defined (HANDLE_MULTIBYTE) #define CHECK_LPOS() \ @@ -785,7 +801,7 @@ rl_redisplay (void) inv_lbreaks = (int *)xrealloc (inv_lbreaks, inv_lbsize * sizeof (int)); \ } \ inv_lbreaks[++newlines] = out; \ - if (newlines >= (line_state_invisible->wbsize - 1)) \ + if (newlines >= (line_state_invisible->wbsize - 2)) \ { \ line_state_invisible->wbsize *= 2; \ line_state_invisible->wrapped_line = (int *)xrealloc (line_state_invisible->wrapped_line, line_state_invisible->wbsize * sizeof(int)); \ @@ -935,6 +951,9 @@ rl_redisplay (void) temp = _rl_screenwidth - lpos; CHECK_INV_LBREAKS (); inv_lbreaks[++newlines] = out + temp; +#if defined (HANDLE_MULTIBYTE) + line_state_invisible->wrapped_line[newlines] = _rl_wrapped_multicolumn; +#endif lpos = 4 - temp; } else @@ -965,6 +984,9 @@ rl_redisplay (void) temp2 = _rl_screenwidth - lpos; CHECK_INV_LBREAKS (); inv_lbreaks[++newlines] = out + temp2; +#if defined (HANDLE_MULTIBYTE) + line_state_invisible->wrapped_line[newlines] = _rl_wrapped_multicolumn; +#endif lpos = temp - temp2; while (out < newout) line[out++] = ' '; @@ -982,6 +1004,9 @@ rl_redisplay (void) line[out++] = '\0'; /* XXX - sentinel */ CHECK_INV_LBREAKS (); inv_lbreaks[++newlines] = out; +#if defined (HANDLE_MULTIBYTE) + line_state_invisible->wrapped_line[newlines] = _rl_wrapped_multicolumn; +#endif lpos = 0; } else if (CTRL_CHAR (c) || c == RUBOUT) @@ -1056,6 +1081,10 @@ rl_redisplay (void) inv_botlin = lb_botlin = _rl_inv_botlin = newlines; CHECK_INV_LBREAKS (); inv_lbreaks[newlines+1] = out; +#if defined (HANDLE_MULTIBYTE) + /* This should be 0 anyway */ + line_state_invisible->wrapped_line[newlines+1] = _rl_wrapped_multicolumn; +#endif cursor_linenum = lb_linenum; /* CPOS_BUFFER_POSITION == position in buffer where cursor should be placed.