[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bug in select-command

From: Eduardo A . Bustamante López
Subject: Re: Bug in select-command
Date: Sat, 24 Jun 2017 12:38:28 -0500
User-agent: NeoMutt/20170113 (1.7.2)

On Sat, Jun 24, 2017 at 01:17:23PM -0400, Chet Ramey wrote:
> You haven't exported these.  If you had, the subshell started to run the
> script would have the correct values.

Hm. I think this may be a documentation / usability problem.

The manual states the following:

         Used  by the select compound command to determine the terminal width
         when printing selection lists.  *Automatically set if the checkwinsize
         option is enabled* or in an interactive shell upon receipt of a


          If set, bash checks the window size after each command and, if
          necessary, updates the values of LINES and COLUMNS.

Furthermore, POSIX [1] says the following:

          This variable shall represent a decimal integer >0 used to indicate
          the user's preferred width in column positions for the terminal
          screen or window; see Column Position. If this variable is unset or
          null, the implementation determines the number of columns,
          appropriate for the terminal or window, in an unspecified manner.
          When COLUMNS is set, any terminal-width information implied by TERM
          is overridden. Users and conforming applications should not set
          COLUMNS unless they wish to override the system selection and produce
          output unrelated to the terminal characteristics.

          Users *should not need to set this variable in the environment*
          unless there is a specific reason to override the implementation's
          default behavior, such as to display data in an area arbitrarily
          smaller than the terminal or window.

So, from the manual alone, I know the following:

- `select' uses the COLUMNS variable to determine the terminal width
- the value of COLUMNS is automatically set if the `checkwinsize' option is
  enabled (** restrictions apply).
- bash checks the window size after each command

I have the following problems with the documentation:

- It seems to imply that it's set automatically *when* `checkwinsize' is
  enabled. A careful reading uncovers that this is not true though, and that
  you have to run a command for the window size to be checked.
- It doesn't mention that the window size is NOT checked after *builtin*
- POSIX recommends against exporting the COLUMNS variable.

I know that I can get the desired behavior by either:

- Running the script under an interactive shell
- Setting `checkwinsize' and running a dummy external command to trigger the
window size check.
- Exporting the COLUMNS variable from the parent interactive shell.

I think that's too much hassle, when bash could easily:

- If the `select' statement is used and `checkwinsize' is set and
  `COLUMNS' is unset, then call `get_new_window_size'
- Call `get_new_window_size' when `checkwinsize' is enabled.


Eduardo Bustamante

reply via email to

[Prev in Thread] Current Thread [Next in Thread]