Explain that COLUMNS and LINES are not set automatically in non-interactive shells, and recommend direct use of the tput utility from ncurses as a replacement.
Fixes: http://bugs.debian.org/628638 Reported-by: Leslie A Rhorer <lrho...@satx.rr.com> Helped-by: Leslie A Rhorer <lrho...@satx.rr.com> --- Hi Chet et al, Here's a quick documentation patch, based on the report mentioned above. Thoughts of all kinds welcome. doc/bash.1 | 14 ++++++++++---- 1 files changed, 10 insertions(+), 4 deletions(-) diff --git a/doc/bash.1 b/doc/bash.1 index 1890b3c..4df0986 100644 --- a/doc/bash.1 +++ b/doc/bash.1 @@ -1802,7 +1802,10 @@ being closed. .TP .B COLUMNS Used by the \fBselect\fP builtin command to determine the terminal width -when printing selection lists. Automatically set upon receipt of a SIGWINCH. +when printing selection lists. Automatically set in interactive shells +upon receipt of a SIGWINCH. +To obtain the width of the terminal in a non-interactive shell, +use \fBCOLUMNS\fP=$(tput cols). .TP .B COMPREPLY An array variable from which \fBbash\fP reads the possible completions @@ -2021,9 +2024,12 @@ This variable determines the locale category used for number formatting. .TP .B LINES Used by the \fBselect\fP builtin command to determine the column length -for printing selection lists. Automatically set upon receipt of a +for printing selection lists. Automatically set in interactive shells +upon receipt of a .SM .BR SIGWINCH . +To obtain the width of the terminal in a non-interactive shell, +use \fBLINES\fP=$(tput lines). .TP .B MAIL If this parameter is set to a file name and the @@ -8732,8 +8738,8 @@ above). The shell always postpones exiting if any jobs are stopped. .TP 8 .B checkwinsize -If set, \fBbash\fP checks the window size after each command -and, if necessary, updates the values of +If set and the shell is interactive, \fBbash\fP checks the window size +after each command and, if necessary, updates the values of .SM .B LINES and -- 1.7.5.3