Skip to content

[bug] Interactive no-tty startup defaults: emacs editing mode off + H missing in $- for --rcfile/-s paths (kills ble.sh at its noediting gate; -i -c $- diverges the other way: hBc vs himBH) #312

Closed

Description

@caomengxuan666

Summary

Interactive-shell startup defaults diverge between rubash and GNU bash 5.3.0 when there is no tty on stdin (the normal shape for --rcfile harnesses, CI, and any scripted -i usage). Two independent divergences:

  1. Editing mode: GNU keeps set -o emacs ON for -i shells regardless of stdin (readline only engages when a line is actually read); rubash leaves emacs/vi OFF in the -i <file>, -i -s, and -i --rcfile paths. (Note: GNU itself turns emacs OFF for plain -i <file> — the one shape where they match.)
  2. $- flags: for -i --rcfile <rc> with stdin=/dev/null, GNU $-=himBH (H = history), rubash $-=himB. For -i -c the divergence is the reverse shape: GNU $-=hBc (no i/m/H), rubash $-=himBH.

Impact (ecosweep2 lane, A4 ble.sh full load): ble.sh aborts at ble.sh:598 ("ble.sh is not intended to be used with the line-editing mode disabled (--noediting)") because [[ ! -o emacs && ! -o vi ]] is true under rubash. With a real PTY GNU loads 1,902 functions (rc=0); rubash with the bleopt_connect_tty TTY-gate bypass gets 33 functions and aborts at the noediting gate. This is the current layer blocker for any PTY-less ble.sh / readline-replacement framework load.

Observed matrix (stdin = /dev/null unless noted)

invocation GNU 5.3.0 $- / emacs rubash @116b12aa $- / emacs
-i --rcfile rc himBH / ON himB / OFF
-i -s (stdin=pipe) himBHs / ON himBHs / OFF
-i file.sh himBH / OFF himBH / OFF (match)
-i -c '…' hBc / ON himBH / ON
-i --rcfile rc under real PTY (script) himBH / ON (n/a — no ConPTY harness; winpty rejects piped stdin)

GNU 5.2.21 cross-check agrees with 5.3.0 on the -i -c row (hBc).

GNU C source anchors (vendored third_party/bash)

  • shell.c:1830 init_interactive() — sets interactive/history defaults and does not set no_line_editing; only shell.c:1853 init_noninteractive() sets no_line_editing = 1. The emacs default for interactive shells comes from the absence of that flag plus shell.c option processing (-o emacs default when no -o vi).
  • History flag H in $-: variables.c/flags rendering from histexp_flag/history_expansion initialized in init_interactive() (shell.c:1830-1842).

Reproducers (script files, run both shells, stdin /dev/null)

# rc / script body
echo "DASH=[$-]"
[[ -o emacs ]] && echo EMACS-ON || echo EMACS-OFF
  • bash --rcfile rc -i </dev/null → GNU: himBH+ON; rubash: himB+OFF
  • echo body | bash -i -s → GNU: ON; rubash: OFF
  • bash -i -c 'echo $-' → GNU: hBc; rubash: himBH

ble.sh evidence: target/issue-suites/results/ecosweep2/ble/ — rb2.out (rubash: 33 fns, noediting abort), gnu3.out (GNU under script -qec: rc=0, FN=1902), optcheck.rc, dashcheck.sh, dash53.out/dash521.out.

Environment

Activity

  1. added
    bug
    on Sep 29, 2026
  2. added 2 commits that reference this issue on Sep 29, 2026
  3. caomengxuan666 commented on Sep 29, 2026

    @caomengxuan666
    MemberAuthor

    Fixed by wt13/sweepfix (9e9b44bb, master 203c2b5): emacs had no default-on point and history/histexpand were set only after init files (rcfile $- missing H). apply_init_interactive_defaults now runs at the top of all three interactive init paths (before rcfiles): history/histexpand/emacs with --noediting (previously ignored, now wired) and -o vi guards; -i script path stays off. NOTE the lane CORRECTED the issue matrix: GNU -i -c is himBHc (verified on 5.3.0 and 5.2.21), the filed hBc row was a misprobe. Anchors: shell.c:540-549/1830-1870, builtins/set.def:446-449. ble.sh noediting gate passes.

  4. caomengxuan666 commented on Oct 17, 2026

    @caomengxuan666
    MemberAuthor

    Real bug found in triage and fixed as PR #697 (branch fix/rcfile-double-source): interactive shells sourced --rcfile twice. File 6/9->9/9; #297 semantics preserved. Gate running.

  5. caomengxuan666 commented on Oct 17, 2026

    @caomengxuan666
    MemberAuthor

    Correction: the fix PR is #712, not #697.

  6. caomengxuan666 commented on Oct 17, 2026

    @caomengxuan666
    MemberAuthor

    Follow-up: the remaining 3 (gate 6/9->9/9) were a real double-source bug — landed as #712 (squash-merged 29f1a28). rcfile now sourced once; non-interactive extension + #297 semantics preserved.

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

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions