diff --git a/CWRU/CWRU.chlog b/CWRU/CWRU.chlog index d18b26ae..459cfb87 100644 --- a/CWRU/CWRU.chlog +++ b/CWRU/CWRU.chlog @@ -10676,3 +10676,41 @@ arrayfunc.c reported by Grisha Levit - convert_var_to_assoc: make sure that the newly-converted associative array variable is not marked as being an indexed array + + 4/22 + ---- +builtins/evalstring.c + - should_suppress_fork: don't suppress the fork if there are any traps + set, since that requires that we hang around to react to a signal or + collect the command's exit status and run something. Fixes bug + reported by Brian Vandenberg + +histexpand.c + - history_tokenize_word: handle >| as a single token. Fix from + Piotr Grzybowski from a report from + idallen@idallen-fibe.dyndns.org + + 4/24 + ---- +execute_cmd. + - coproc_setvars: don't overwrite readonly variables used as coproc + names. From a report from Grisha Levit + +histexpand.c + - history_tokenize_word: handle strings of digits before redirections + beginning with `<' or `>' as part of the redirection word; handle + strings of digits following `<&' or `>&' as part of the redirection + word. Inspired by patch from Piotr Grzybowski + from a report from idallen@idallen-fibe.dyndns.org + +lib/readline/complete.c + - rl_display_match_list: if the common prefix is longer than any of + the possible matches, set the length of the common prefix to 0 so + the entire match gets printed for each match + - rl_display_match_list: make sure to output at least one space + between each displayed match, even if the displayed length is + longer than our computed max + - fnprint: if the length of the prefix (prefix_bytes) is greater than + or equal to the length of the string to be printed (print_len), make + sure to set the prefix length to 0 so the entire string is printed. + From a report from Grisha Levit diff --git a/builtins/evalstring.c b/builtins/evalstring.c index f27d1b3b..eed137fb 100644 --- a/builtins/evalstring.c +++ b/builtins/evalstring.c @@ -104,7 +104,12 @@ should_suppress_fork (command) running_trap == 0 && *bash_input.location.string == '\0' && command->type == cm_simple && +#if 0 signal_is_trapped (EXIT_TRAP) == 0 && + signal_is_trapped (ERROR_TRAP) == 0 && +#else + any_signals_trapped () < 0 && +#endif command->redirects == 0 && command->value.Simple->redirects == 0 && ((command->flags & CMD_TIME_PIPELINE) == 0) && ((command->flags & CMD_INVERT_RETURN) == 0)); @@ -384,7 +389,8 @@ parse_and_execute (string, from_file, flags) * we're not going to run the exit trap AND * we have a simple command without redirections AND * the command is not being timed AND - * the command's return status is not being inverted + * the command's return status is not being inverted AND + * there aren't any traps in effect * THEN * tell the execution code that we don't need to fork */ diff --git a/execute_cmd.c b/execute_cmd.c index 3d4d3e8a..82d9ee00 100644 --- a/execute_cmd.c +++ b/execute_cmd.c @@ -2171,14 +2171,14 @@ coproc_setvars (cp) #if defined (ARRAY_VARS) v = find_variable (cp->c_name); -# if 0 + if (v && (readonly_p (v) || noassign_p (v))) { if (readonly_p (v)) err_readonly (cp->c_name); return; } -# endif + if (v == 0) v = make_new_array_variable (cp->c_name); if (array_p (v) == 0) @@ -2229,7 +2229,7 @@ coproc_unsetvars (cp) unbind_variable (namevar); #if defined (ARRAY_VARS) - unbind_variable (cp->c_name); + check_unbind_variable (cp->c_name); #else sprintf (namevar, "%s_READ", cp->c_name); unbind_variable (namevar); diff --git a/lib/readline/complete.c b/lib/readline/complete.c index 6453f86e..0a81129b 100644 --- a/lib/readline/complete.c +++ b/lib/readline/complete.c @@ -807,7 +807,7 @@ fnprint (to_print, prefix_bytes, real_pathname) { int printed_len, w; const char *s; - int common_prefix_len; + int common_prefix_len, print_len; #if defined (HANDLE_MULTIBYTE) mbstate_t ps; const char *end; @@ -815,7 +815,8 @@ fnprint (to_print, prefix_bytes, real_pathname) int width; wchar_t wc; - end = to_print + strlen (to_print) + 1; + print_len = strlen (to_print); + end = to_print + print_len + 1; memset (&ps, 0, sizeof (mbstate_t)); #endif @@ -825,7 +826,7 @@ fnprint (to_print, prefix_bytes, real_pathname) possible completions. Only cut off prefix_bytes if we're going to be printing the ellipsis, which takes precedence over coloring the completion prefix (see print_filename() below). */ - if (_rl_completion_prefix_display_length > 0 && to_print[prefix_bytes] == '\0') + if (_rl_completion_prefix_display_length > 0 && prefix_bytes >= print_len) prefix_bytes = 0; #if defined (COLOR_SUPPORT) @@ -1575,6 +1576,8 @@ rl_display_match_list (matches, len, max) temp = rl_filename_completion_desired ? strrchr (t, '/') : 0; common_length = temp ? fnwidth (temp) : fnwidth (t); sind = temp ? strlen (temp) : strlen (t); + if (common_length > max || sind > max) + common_length = sind = 0; if (common_length > _rl_completion_prefix_display_length && common_length > ELLIPSIS_LEN) max -= common_length - ELLIPSIS_LEN; @@ -1588,6 +1591,8 @@ rl_display_match_list (matches, len, max) temp = rl_filename_completion_desired ? strrchr (t, '/') : 0; common_length = temp ? fnwidth (temp) : fnwidth (t); sind = temp ? RL_STRLEN (temp+1) : RL_STRLEN (t); /* want portion after final slash */ + if (common_length > max || sind > max) + common_length = sind = 0; } #endif @@ -1636,8 +1641,13 @@ rl_display_match_list (matches, len, max) printed_len = print_filename (temp, matches[l], sind); if (j + 1 < limit) - for (k = 0; k < max - printed_len; k++) - putc (' ', rl_outstream); + { + if (max <= printed_len) + putc (' ', rl_outstream); + else + for (k = 0; k < max - printed_len; k++) + putc (' ', rl_outstream); + } } l += count; } @@ -1684,6 +1694,8 @@ rl_display_match_list (matches, len, max) return; } } + else if (max <= printed_len) + putc (' ', rl_outstream); else for (k = 0; k < max - printed_len; k++) putc (' ', rl_outstream); diff --git a/lib/readline/histexpand.c b/lib/readline/histexpand.c index fdecebcb..457cdb4c 100644 --- a/lib/readline/histexpand.c +++ b/lib/readline/histexpand.c @@ -1421,7 +1421,7 @@ history_tokenize_word (string, ind) const char *string; int ind; { - register int i; + register int i, j; int delimiter, nestdelim, delimopen; i = ind; @@ -1433,6 +1433,22 @@ history_tokenize_word (string, ind) return i; } + if (isdigit (string[i])) + { + j = i; + while (string[j] && isdigit (string[j])) + j++; + if (string[j] == 0) + return (j); + if (string[j] == '<' || string[j] == '>') + i = j; /* digit sequence is a file descriptor */ + else + { + i = j; + goto get_word; /* digit sequence is part of a word */ + } + } + if (member (string[i], "<>;&|$")) { int peek = string[i + 1]; @@ -1446,8 +1462,16 @@ history_tokenize_word (string, ind) i += 2; return i; } - else if ((peek == '&' && (string[i] == '>' || string[i] == '<')) || - (peek == '>' && string[i] == '&')) + else if (peek == '&' && (string[i] == '>' || string[i] == '<')) + { + j = i + 2; + while (string[j] && isdigit (string[j])) /* file descriptor */ + j++; + if (string[j] =='-') /* <&[digits]-, >&[digits]- */ + j++; + return j; + } + else if ((peek == '>' && string[i] == '&') || (peek == '|' && string[i] == '>')) { i += 2; return i; diff --git a/lib/readline/histlib.h b/lib/readline/histlib.h index c938a109..28cad14a 100644 --- a/lib/readline/histlib.h +++ b/lib/readline/histlib.h @@ -76,7 +76,4 @@ extern char *strchr (); #define HISTORY_APPEND 0 #define HISTORY_OVERWRITE 1 -/* Some variable definitions shared across history source files. */ -extern int history_offset; - #endif /* !_HISTLIB_H_ */ diff --git a/lib/readline/misc.c b/lib/readline/misc.c index 4fc57e78..f7acdee0 100644 --- a/lib/readline/misc.c +++ b/lib/readline/misc.c @@ -56,8 +56,6 @@ static int rl_digit_loop PARAMS((void)); static void _rl_history_set_point PARAMS((void)); -extern int history_offset; - /* Forward declarations used in this file */ void _rl_free_history_entry PARAMS((HIST_ENTRY *));