diff --git a/CWRU/CWRU.chlog b/CWRU/CWRU.chlog index 00819cbf..01284d64 100644 --- a/CWRU/CWRU.chlog +++ b/CWRU/CWRU.chlog @@ -14199,3 +14199,28 @@ expr.c doc/{bash.1,bashref.texi} - add text noting that $* and ${array[*]} (unquoted) can also expand to multiple words + + 6/29 + ---- +general.[ch] + - default_columns: new function, returns the value of COLUMNS, or + refreshes it if check_window_size is set and COLUMNS is unset. By + default, it returns 80 + +execute_cmd.c + - select_query: use default_columns() instead of fetching value of + COLUMNS directly + +builtins/help.def + - show_builtin_command_help: use default_columns() instead of fetching + value of COLUMNS directly + + 6/30 + ---- +builtins/read.def + - read_builtin: call QUIT during the read loop, just in case we get a + signal we should act on that didn't cause read to be interrupted. + Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1466737 + - read_builtin: if -n or -N is supplied with a 0 argument, try a zero- + length read to detect errors and return failure if that read returns + a value < 0. Suggested by dualbus@gmail.com diff --git a/builtins/help.def b/builtins/help.def index 3b83c8ba..35289480 100644 --- a/builtins/help.def +++ b/builtins/help.def @@ -530,10 +530,7 @@ Use `man -k' or `info' to find out more about commands not in this list.\n\ A star (*) next to a name means that the command is disabled.\n\ \n")); - t = get_string_value ("COLUMNS"); - width = (t && *t) ? atoi (t) : 80; - if (width <= 0) - width = 80; + width = default_columns (); width /= 2; if (width > sizeof (blurb)) diff --git a/builtins/read.def b/builtins/read.def index 7fa8f86a..a4ec0654 100644 --- a/builtins/read.def +++ b/builtins/read.def @@ -1,7 +1,7 @@ This file is read.def, from which is created read.c. It implements the builtin "read" in Bash. -Copyright (C) 1987-2015 Free Software Foundation, Inc. +Copyright (C) 1987-2017 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. @@ -364,7 +364,11 @@ read_builtin (list) /* More input and options validation */ if (nflag == 1 && nchars == 0) - goto assign_vars; /* bail early if asked to read 0 chars */ + { + retval = read (fd, &c, 0); + retval = (retval >= 0) ? EXECUTION_SUCCESS : EXECUTION_FAILURE; + goto assign_vars; /* bail early if asked to read 0 chars */ + } /* $TMOUT, if set, is the default timeout for read. */ if (have_timeout == 0 && (e = get_string_value ("TMOUT"))) @@ -609,7 +613,7 @@ read_builtin (list) } CHECK_ALRM; - + QUIT; /* in case we didn't call check_signals() */ #if defined (READLINE) } #endif diff --git a/doc/bash.1 b/doc/bash.1 index 42419d33..a0a7be43 100644 --- a/doc/bash.1 +++ b/doc/bash.1 @@ -119,7 +119,8 @@ If the option is present, or if no arguments remain after option processing, then commands are read from the standard input. This option allows the positional parameters to be set -when invoking an interactive shell. +when invoking an interactive shell or when reading input +through a pipe. .TP .B \-D A list of all double-quoted strings preceded by \fB$\fP diff --git a/doc/bashref.texi b/doc/bashref.texi index 0bf126d4..e132b587 100644 --- a/doc/bashref.texi +++ b/doc/bashref.texi @@ -6414,7 +6414,8 @@ Make the shell a restricted shell (@pxref{The Restricted Shell}). If this option is present, or if no arguments remain after option processing, then commands are read from the standard input. This option allows the positional parameters to be set -when invoking an interactive shell. +when invoking an interactive shell or when reading input +through a pipe. @item -D A list of all double-quoted strings preceded by @samp{$} diff --git a/execute_cmd.c b/execute_cmd.c index a006b3d3..4d71932b 100644 --- a/execute_cmd.c +++ b/execute_cmd.c @@ -3185,12 +3185,7 @@ select_query (list, list_len, prompt, print_menu) WORD_LIST *l; char *repl_string, *t; -#if 0 - t = get_string_value ("LINES"); - LINES = (t && *t) ? atoi (t) : 24; -#endif - t = get_string_value ("COLUMNS"); - COLS = (t && *t) ? atoi (t) : 80; + COLS = default_columns (); #if 0 t = get_string_value ("TABSIZE"); diff --git a/general.c b/general.c index 3c0885a9..adef2d8f 100644 --- a/general.c +++ b/general.c @@ -1346,3 +1346,26 @@ conf_standard_path () # endif /* !CS_PATH */ #endif /* !_CS_PATH || !HAVE_CONFSTR */ } + +int +default_columns () +{ + char *v; + int c; + + c = -1; + v = get_string_value ("COLUMNS"); + if (v && *v) + { + c = atoi (v); + if (c > 0) + return c; + } + + if (check_window_size) + get_new_window_size (0, (int *)0, &c); + + return (c > 0 ? c : 80); +} + + diff --git a/general.h b/general.h index 73fc7761..7777bb7a 100644 --- a/general.h +++ b/general.h @@ -335,5 +335,6 @@ extern char **get_group_list __P((int *)); extern int *get_group_array __P((int *)); extern char *conf_standard_path __P((void)); +extern int default_columns __P((void)); #endif /* _GENERAL_H_ */ diff --git a/lib/sh/zread.c b/lib/sh/zread.c index 496f20b8..14b66381 100644 --- a/lib/sh/zread.c +++ b/lib/sh/zread.c @@ -1,6 +1,6 @@ /* zread - read data from file descriptor into buffer with retries */ -/* Copyright (C) 1999-2002 Free Software Foundation, Inc. +/* Copyright (C) 1999-2017 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. diff --git a/shell.h b/shell.h index 9e0704bc..ded8c3c7 100644 --- a/shell.h +++ b/shell.h @@ -119,6 +119,7 @@ extern char **subshell_envp; extern int hup_on_exit; extern int check_jobs_at_exit; extern int autocd; +extern int check_window_size; /* from version.c */ extern int build_version, patch_level;