Skip to content

[bug] Interactive startup never initializes COLUMNS/LINES without a tty: GNU binds 80/24 via readline defaults — OMB iterate theme dies at $(($COLUMNS/1)) #300

Closed

Description

@caomengxuan666

Found by the ecosweep lane (wt10/ecosweep, 2026-09-28) triaging the oh-my-bash 83-theme matrix (rubash e207b0d).

Minimal reproducer (rcfile, -i, </dev/null, both shells)

rcfile:

echo "COLUMNS=${COLUMNS-UNSET}"
echo "r=$((COLUMNS/1))"
echo "d=$(($COLUMNS/1))"
  • GNU bash 5.3.0 (WSL /usr/local/bin/bash): COLUMNS=80, r=80, d=80, rc 0.
  • rubash: COLUMNS=UNSET, r=0, stderr /1: arithmetic syntax error: operand expected (error token is "/1"), rc 1.

GNU initializes COLUMNS/LINES to the readline screen-size defaults (80x24) during
interactive startup even when there is no controlling terminal; rubash leaves them unset,
so any $(($COLUMNS...))-style prompt code (the $-prefixed arithmetic form, which performs
parameter expansion before evaluation) breaks.

Real-world impact

  • oh-my-bash themes/iterate/iterate.theme.sh:47:
    [[ ${#new_PS1} -gt $(($COLUMNS/1)) ]] && wrap_char="\n" →
    /1: arithmetic syntax error on every prompt under rubash (PROMPT_COMMAND stderr noise;
    PS1 falls back). The same theme run under GNU (LF OMB copy) is error-free
    (target/issue-suites/results/ecosweep/probes/diag-it-gnu.err, 0 arithmetic errors).

GNU C anchor

lib/sh/winsize.c:100 calls sh_set_lines_and_columns(win.ws_row, win.ws_col)
(variables.c:1040, binds LINES then COLUMNS); when no winsize is available the readline
terminal setup binds the 80x24 defaults — lib/readline/terminal.c:374
(sh_set_lines_and_columns (_rl_screenheight, _rl_screenwidth)), reached during
interactive-shell readline initialization (shell.c:547 init_interactive).

Artifacts

  • target/issue-suites/results/ecosweep/probes/t3.rc + t3.{rb,gnu}.{out,err}
  • target/issue-suites/results/ecosweep/omb/themes/iterate.{pcerr,err} + diag-it-gnu.err

Activity

  1. added
    bug
    gnu-baseline
    on Sep 28, 2026
  2. added a commit that references this issue on Sep 28, 2026
  3. caomengxuan666 commented on Sep 28, 2026

    @caomengxuan666
    MemberAuthor

    Fixed by wt11/inter3 (cf39a2d4, master): COLUMNS/LINES now follow GNU's dual mechanism — get_tty_state at startup-job-control and post-rcfile points (jobs.c:4871 -> :2647 -> winsize.c:98-100; CONOUT$ screen-buffer visible rect = TIOCGWINSZ semantics) and _rl_get_screen_size at first prompt (terminal.c:293-374 via bashline.c:524: console -> positive-bound guard :640-643 -> env -> 80x24 default :366-371), bound as non-exported shell variables (variables.c:1040). Verified: DETACHED process PROMPT_COMMAND sees C=80/L=24 with clean arithmetic; console session sees real size; WSL harness's 1x1 console yields LINES=1 on GNU too (mechanism confirmed via gdb+strace). 10 new regressions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    buggnu-baseline

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions