Skip to content

Letter 'b' is replaced by 'set enaset enaset enaset enaset enaset enaset enaset enaset enaset enaset enaset enaset enaset enaset enaset enaset ena' #1583

@lennylxx

Description

@lennylxx

Describe the bug

I was using Claude Opus 4.6 (fast mode), I told it to commit a git, and the message it generates contains a lot of letter b, after it committed, I used another shell to confirm with git log, found out a lot of b is replaced by set enaset enaset enaset enaset enaset enaset enaset enaset enaset enaset enaset enaset enaset enaset enaset enaset ena.

So I asked it to scan my shell setup and find out what causes the issue, and it says it's GitHub Copilot CLI.
Check Additional context for the full transcript.

Affected version

GitHub Copilot CLI 0.0.413

Steps to reproduce the behavior

Type echo "test: a-b-c-d-e-f" | cat -v in GitHub Copilot CLI.
Mine outputs this

● Test b character output
  $ echo "test: a-b-c-d-e-f" | cat -v
  └ 2 lines...

● There it is — the b in the echo string got replaced with set ena... repeated 17 times. This confirms it's happening at the input level when the copilot CLI writes
  the command to the PTY. The b never reaches bash as b.

Expected behavior

No response

Additional context

❯ scan my shell setup, figure out what is causing the letter b problem, tell me where , but don't fix it.

● Check default shell
  $ echo $SHELL
  └ 2 lines...

● Check current shell
  $ echo $0
  └ 2 lines...

● Search rc files for b binding
  $ grep -rn "enaset\|ena set\|'b'" ~/.bashrc ~/.bash_profile ~/.profile ~/.inputrc /etc/inputrc 2>/dev/null | head -20
  └ 1 line...

● List shell config files
  $ ls -la ~/.bashrc ~/.bash_profile ~/.profile ~/.inputrc ~/.zshrc ~/.zprofile ~/.zshenv 2>/dev/null
  └ 5 lines...

● Read ~/.zshrc
  └ 132 lines read

● Read ~/.zshenv
  └ 1 line read

● Read ~/.zprofile
  └ 1 line read

● Read ~/.profile
  └ 28 lines read

● The .zshrc sources ~/dotfiles/init.sh at line 120. Let me check that.

● Read ~/dotfiles/init.sh
  └ 21 lines read

● Nothing there. The issue must be from the bash environment specifically. Let me check if there's a bash-level bind or trap causing this.

● Check bash key bindings
  $ bind -p 2>/dev/null | grep '"\\C-' | head -20
  └ 1 line...

● Check bash traps
  $ trap -p
  └ 1 line...

● Check PROMPT_COMMAND
  $ echo "$PROMPT_COMMAND"
  └ 1 line...

● Check terminal settings
  $ stty -a 2>/dev/null | tr ';' '\n' | grep -i 'ena\|set'
  └ 1 line...

● Full terminal settings
  $ stty -a 2>/dev/null
  └ 8 lines...

● Check PS1 prompt
  $ printf '%q\n' "$PS1"
  └ 2 lines...

● Check bash options
  $ set -o | head -30
  └ 28 lines...

● Check readline bindings
  $ bind -x 2>/dev/null | head -20; echo "---"; bind -s 2>/dev/null | head -20
  └ 2 lines...

● Active readline bindings
  $ bind -p 2>/dev/null | grep -v "not bound" | grep -v "self-insert" | head -30
  └ 1 line...

● Let me check if there's a preexec or DEBUG trap from the parent zsh that's interfering.

● Check BASH_ENV and readline env
  $ echo $BASH_ENV; echo "---"; env | grep -iE "BASH|READLINE|INPUTRC" | head -10
  └ 2 lines...

● Check if b in pipe works
  $ echo "test: a-c-d-e-f" | cat -v
  └ 2 lines...

● Interesting — the b was stripped from the echo output too! The word "a-b-c-d-e-f" became "a-c-d-e-f". Let me test more carefully.

● Print b via hex escape
  $ printf 'a\x62c\n'
  └ 2 lines...

● That works! So \x62 (which is b) passes through fine via printf. The problem is specifically the literal character b being intercepted at the input/terminal level before the shell parses it.

● Check process environ
  $ cat /proc/$$/environ 2>/dev/null | tr '\0' '\n' | grep -i "preexec\|DEBUG\|TRAP\|vscode\|terminal" | head -10
  └ 1 line...

● Check terminal type
  $ cat /proc/$$/environ 2>/dev/null | tr '\0' '\n' | grep -i "TERM\|VSCODE" | head -10
  └ 2 lines...

● Check VS Code terminal env
  $ echo $TERM_PROGRAM; echo "---"; echo $TERM_PROGRAM_VERSION; echo "---"; env | grep -i vscode | head -5
  └ 4 lines...

● Check parent process
  $ cat /proc/$PPID/cmdline 2>/dev/null | tr '\0' ' '; echo; echo "---"; cat /proc/$$/cmdline 2>/dev/null | tr '\0' ' '; echo
  └ 4 lines...

● So the parent is the copilot CLI agent, and our shell is bash --norc --noprofile. The corruption is happening before bash gets the input — likely the copilot CLI's PTY handling. But let me verify it's not something in the terminal configuration.

● Check terminfo for set/ena
  $ infocmp $TERM 2>/dev/null | grep -i "set\|ena" | head -10
  └ 3 lines...

● Found it! Let me get the full terminfo entry.

● Full terminfo for xterm-color
  $ infocmp $TERM 2>/dev/null
  └ 29 lines...

● The key line is:

   cub1=^H,

  cub1 is "cursor back 1" and it's mapped to ^H which is ASCII 8 (backspace). But that's normal. Let me look at this differently — the enacs=\E)0 is the "enable alternate character set" capability. Let me check if something is sending \E)0 (the enacs sequence) when it sees b.

  Actually, let me re-examine the corruption pattern more carefully:

● Verify b character encoding
  $ printf '\x62\n' | od -c | head
  └ 3 lines...

● Check parent process details
  $ cat /proc/$PPID/status | head -5; echo "---"; ls -la /proc/$PPID/fd/0 2>/dev/null
  └ 8 lines...

● Check process tree
  $ pstree -p $PPID 2>/dev/null | head -10
  └ 11 lines...

● Check our PTY
  $ ls -la /proc/$$/fd/0 2>/dev/null; echo "---"; tty
  └ 4 lines...

● Compare PTY settings
  $ stty -a < /dev/pts/28 2>/dev/null | head -5; echo "==="; stty -a < /dev/pts/26 2>/dev/null | head -5
  └ 12 lines...

● Our PTY (pts/28) has eol = M-^?; eol2 = M-^? which is unusual — those are set to \x{ff} (meta-delete). The parent terminal (pts/26) has them as <undef>. But this shouldn't cause the b issue.

  Let me look more carefully at the actual pattern. When I type build in a command, it gets transformed. Let me check if it's related to the VS Code terminal shell integration.

● Dump full environment
  $ env | sort > /tmp/env.txt && wc -l /tmp/env.txt
  └ 2 lines...

● Read /tmp/env.txt
  └ 51 lines read

● Check fzf zsh integration
  $ ls -la ~/.fzf.zsh 2>/dev/null && head -20 ~/.fzf.zsh
  └ 9 lines...

● Check p10k config
  $ ls ~/.p10k.zsh 2>/dev/null && wc -l ~/.p10k.zsh
  └ 3 lines...

● The copilot CLI is the parent process (PID 1303349). It creates PTYs for bash subshells. The b corruption pattern — every b becomes a long set ena... string — points to the copilot CLI's PTY input handling interpreting the byte 0x62 (b) as an ANSI escape sequence or control
  code and expanding it.

  This is not caused by your shell configuration (.zshrc, .p10k.zsh, .fzf.zsh, dotfiles/init.sh). The bash shells are launched with --norc --noprofile, have no traps, no PROMPT_COMMAND, no custom bindings, and the b character works fine when it goes through printf '\x62' or
  file I/O. The corruption only happens when the literal character b is sent as terminal input through the copilot CLI's PTY layer.

  Root cause: It's a bug in the GitHub Copilot CLI tool (version 0.0.413) — specifically in how it writes command text to the PTY's stdin. The letter b is being misinterpreted, likely as part of an ANSI escape sequence processing in the PTY write path. The set ena expansion
  matches the terminfo enacs=\E)0 (enable alternate character set) capability for TERM=xterm-color, suggesting the CLI's terminal emulation is incorrectly processing certain bytes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions