This may have been meant for everyone. On Mon, May 11, 2026 at 6:47 AM Ilya Tsoy <[email protected]> wrote: > > Zack, > > Thanks for the context and the link to the April thread — I hadn’t > found that. It clarifies that the discrepancy is known and that the > question is about which direction to converge: documentation, or > behavior. > > The practical case I hit was a tally array literally named LINES in > a status-report script, silently overwritten with the terminal height > on every external command. Diagnosis took several rounds because the > bug only reproduces with a controlling TTY, so cron and ssh-without-tty > runs were clean. Point taken on all-caps variables — I've renamed it > and added a note to my coding conventions. > > On the substantive question, I think Chet's concern about honoring > env-passed LINES/COLUMNS is well-founded, and your suggestion to > disable checkwinsize automatically when either variable is inherited > from the environment seems like the cleanest path — it preserves the > existing contract for users who explicitly set them, and stops the > silent mutation for everyone else. > > A smaller, no-behavior-change improvement that might be uncontroversial > in the meantime: the manual entries for LINES and COLUMNS could note > that scripts using these names as user variables may have their values > overwritten when checkwinsize is active. That at least gives the next > person who hits this a fighting chance at finding it via grep'ing the > man page. > > Happy to draft a man-page patch if there's interest. > > — > Ilya Tsoy > github.com/ilvits
I posted the current manual's descriptions of these variables because I thought it already made it clear that bash sets them in a noninteractive shell if checkwinsize is enabled. > ------ Original Message ------ > From "Zachary Santer" <[email protected]> > To "Ilya Tsoy" <[email protected]> > Cc [email protected] > Date 11.05.2026 00:10:03 > Subject Re: [doc] LINES/COLUMNS auto-update in non-interactive shells > contradicts manual > > >The current devel branch (commit 669b32f676) manual says this: > >COLUMNS 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 SIGWINCH. > >LINES Used by the select compound command to determine the column > >length for printing selection lists. Automatically set if the > >checkwinsize option is enabled or in an interactive shell upon receipt > >of a SIGWINCH. > >Automatically set if the > >checkwinsize option is enabled OR in an interactive shell upon receipt > >of a SIGWINCH. "[I]f the checkwinsize option is enabled," regardless of whether or not you're in an interactive shell. "[U]pon receipt of a SIGWINCH," only if you're in an interactive shell. If anything is undocumented, with the current implementation, it's that they're only set each time an external command or foreground subshell executes. If the script isn't outputting to a TTY, then naturally there are no line or column counts to report, but maybe that point could be clarified. $ cat ~/random/COLUMNS #!/usr/bin/env bash declare -p BASH_VERSION shopt -s lastpipe shopt -po posix shopt -p checkwinsize declare -p COLUMNS /bin/true | declare -p COLUMNS ( : ) declare -p COLUMNS $ ./bash ~/random/COLUMNS declare -- BASH_VERSION="5.3.9(1)-maint" set +o posix shopt -s checkwinsize /home/zsant/random/COLUMNS: line 9: declare: COLUMNS: not found /home/zsant/random/COLUMNS: line 11: declare: COLUMNS: not found declare -- COLUMNS="230"
