Public bug reported:

bash 5.1.16 (Ubuntu 22.04, package bash 5.1-6ubuntu1.x)

The bash(1) man page states that LINES and COLUMNS are "automatically
set ... in an interactive shell upon receipt of a SIGWINCH". In
practice, both variables are also updated in non-interactive shells
whenever the shell evaluates a command that queries terminal geometry
via ioctl(TIOCGWINSZ).

Reproducer:

  cat > /tmp/demo.sh << 'EOF'
  #!/bin/bash
  LINES=()
  LINES+=("hello")
  echo "BEFORE: ${LINES[0]}"
  ss -tln >/dev/null 2>&1
  echo "AFTER:  ${LINES[0]}"
  EOF

  bash /tmp/demo.sh                          # from a TTY: prints terminal 
height
  ssh user@host 'bash /tmp/demo.sh'          # without -tt: prints "hello"

Expected: behavior consistent with documentation, OR documentation
updated to reflect the actual behavior.

The practical impact is silent corruption of scripts using LINES or
COLUMNS as user-defined variables. The bug only reproduces from a
TTY, so it does not appear in CI, cron, or ssh-without-tty runs,
making it particularly hard to diagnose.

This is upstream behavior, not Ubuntu-specific. Reporting here for
distribution-level visibility; an upstream report has been filed on
[email protected] [link after sending].

ProblemType: Bug
DistroRelease: Ubuntu 22.04
Package: bash 5.1-6ubuntu1.x
ProcVersionSignature: Ubuntu 5.15.0-173.x-generic 5.15.x
Uname: Linux 5.15.0-173-generic x86_64

** Affects: bash (Ubuntu)
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2152122

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

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/bash/+bug/2152122/+subscriptions


-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to