Re: [doc] LINES/COLUMNS auto-update in non-interactive shells contradicts manual

Chet Ramey <[email protected]> Wed, 13 May 2026 13:22:05 -0400
Newsgroups gmane.comp.shells.bash.bugs
Message-ID <[email protected]>
On 5/12/26 12:32 PM, Zachary Santer wrote:
> On Tue, May 12, 2026 at 10:07 AM Chet Ramey <[email protected]> wrote:
>>
>> On 5/11/26 4:06 PM, Zachary Santer wrote:
>>>
>>> Huh? Yeah, I would be one of those people.
>>
>> Oh, OK. I thought your proposal would have bash unset `checkwinsize' if
>> it found LINES or COLUMNS in the initial environment.
>>
>> Since many (most) terminal emulators set LINES and COLUMNS in the
>> environment they provide to the shell they invoke, and bash exports
>> variables it finds in its environment, this would effectively disable
>> any default that had it enabled.
> 
> I didn't know the initial values for LINES and COLUMNS were exported
> from the terminal emulator.

I got curious, so I looked at this on Fedora 44, which runs bash-5.3.9.

It looks like I fooled myself. I couldn't tell where it was being set
until I hit on the job control code initializing the known terminal
state before running any commands. If `checkwinsize' is set, that sets
LINES and COLUMNS, so they are set in interactive shells but not
(initially) in non-interactive ones, since job control is not enabled.

> If they were always exported from the environment, then they'd at
> least not be initially unset in a noninteractive shell, which would
> help.

Right. They are initially unset in non-interactive shells unless the
calling shell exports them.

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
		 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    [email protected]    http://tiswww.cwru.edu/~chet/