Public bug reported:

When a filename contains a Unicode character outside the Basic
Multilingual Plane (specifically U+1D70B, MATHEMATICAL ITALIC SMALL PI,
`𝜋`), `ls` fails to display it correctly when writing to an SSH pty. The
character is either replaced with `????` or escaped to its octal
representation (`\360\235\234\213`), depending on the quoting style
used.

The bug does not reproduce on a local pty (tested on the same Ubuntu
26.04 machine with a display), and does not reproduce when `ls` writes
to a pipe. It is therefore specific to SSH pty output.

## Environment

- Ubuntu 26.04 (both client and server)
- ls (uutils coreutils) 0.8.0
- LANG=en_US.UTF-8
- TERM=xterm-256color
- Tested across multiple terminal emulators (xfce4-terminal, Terminator, Kitty) 
— all affected identically

## Reproduction

Create a file with a SMP Unicode character in its name on a remote
machine:

`touch $'𝜋thon'`

Then from a client, compare pty vs non-pty SSH:

```
ssh -t user@remote 'ls'   # broken: shows ???? or octal escape
ssh -T user@remote 'ls'   # correct: shows 𝜋thon
```

Local comparison — piped vs tty:

```
ls        # broken
ls | cat  # correct
```

## Quoting style matrix (all styles tested, SSH pty)

All 8 supported quoting styles either escape the character to octal or
display replacement characters. No quoting style passes the raw UTF-8
bytes through correctly when writing to an SSH pty:

```
literal:              ????thon
shell:                ????thon
shell-always:         '????thon'
shell-escape:         ''$'\360\235\234\213''thon'
shell-escape-always:  ''$'\360\235\234\213''thon'
locale:               '\360\235\234\213thon'
clocale:              "\360\235\234\213thon"
c:                    "\360\235\234\213thon"
```

When piped (`ls | grep thon`), `literal`, `shell`, and `shell-always`
all render `𝜋thon` correctly.

## Additional notes

- `echo '𝜋thon'` renders correctly in the same SSH session, ruling out locale 
or terminal font issues
- `python3 -c "import ctypes; libc = ctypes.CDLL('libc.so.6'); 
libc.wcwidth.restype = ctypes.c_int; print(libc.wcwidth(0x1D70B))"` returns `1` 
— glibc considers this a valid, narrow character
- GNU coreutils `ls` behaviour was not tested as it is no longer available on 
Ubuntu 26.04 without manual intervention

ProblemType: Bug
DistroRelease: Ubuntu 26.04
Package: coreutils 9.5-1ubuntu2+0.0.0~ubuntu25
ProcVersionSignature: Ubuntu 7.0.0-29.29-generic 7.0.12
Uname: Linux 7.0.0-29-generic x86_64
ApportVersion: 2.34.1-0ubuntu0.1
Architecture: amd64
CasperMD5CheckResult: pass
CurrentDesktop: XFCE
Date: Mon Aug 10 00:18:42 2026
InstallationDate: Installed on 2025-10-28 (285 days ago)
InstallationMedia: Xubuntu 24.04.1 LTS "Noble Numbat" - Release amd64 (20240827)
PackageArchitecture: all
ProcEnviron:
 LANG=en_US.UTF-8
 PATH=(custom, no user)
 SHELL=/bin/bash
 TERM=xterm-256color
 XDG_RUNTIME_DIR=<set>
SourcePackage: coreutils-from
UpgradeStatus: Upgraded to resolute on 2026-01-22 (199 days ago)

** Affects: coreutils-from (Ubuntu)
     Importance: Undecided
         Status: New


** Tags: amd64 apport-bug resolute

** Description changed:

  When a filename contains a Unicode character outside the Basic
  Multilingual Plane (specifically U+1D70B, MATHEMATICAL ITALIC SMALL PI,
  `𝜋`), `ls` fails to display it correctly when writing to an SSH pty. The
  character is either replaced with `????` or escaped to its octal
  representation (`\360\235\234\213`), depending on the quoting style
  used.
  
  The bug does not reproduce on a local pty (tested on the same Ubuntu
  26.04 machine with a display), and does not reproduce when `ls` writes
  to a pipe. It is therefore specific to SSH pty output.
  
  ## Environment
  
  - Ubuntu 26.04 (both client and server)
- - `ls (uutils coreutils) 0.8.0`
- - `LANG=en_US.UTF-8`
- - `TERM=xterm-256color`
+ - ls (uutils coreutils) 0.8.0
+ - LANG=en_US.UTF-8
+ - TERM=xterm-256color
  - Tested across multiple terminal emulators (xfce4-terminal, Terminator, 
Kitty) — all affected identically
  
  ## Reproduction
  
  Create a file with a SMP Unicode character in its name on a remote
  machine:
  
- ```bash
- touch $'𝜋thon'
- ```
+ `touch $'𝜋thon'`
  
  Then from a client, compare pty vs non-pty SSH:
  
- ```bash
+ ```
  ssh -t user@remote 'ls'   # broken: shows ???? or octal escape
  ssh -T user@remote 'ls'   # correct: shows 𝜋thon
  ```
  
  Local comparison — piped vs tty:
  
- ```bash
+ ```
  ls        # broken
  ls | cat  # correct
  ```
  
  ## Quoting style matrix (all styles tested, SSH pty)
  
  All 8 supported quoting styles either escape the character to octal or
  display replacement characters. No quoting style passes the raw UTF-8
  bytes through correctly when writing to an SSH pty:
  
  ```
  literal:              ????thon
  shell:                ????thon
  shell-always:         '????thon'
  shell-escape:         ''$'\360\235\234\213''thon'
  shell-escape-always:  ''$'\360\235\234\213''thon'
  locale:               '\360\235\234\213thon'
  clocale:              "\360\235\234\213thon"
  c:                    "\360\235\234\213thon"
  ```
  
  When piped (`ls | grep thon`), `literal`, `shell`, and `shell-always`
  all render `𝜋thon` correctly.
  
  ## Additional notes
  
  - `echo '𝜋thon'` renders correctly in the same SSH session, ruling out locale 
or terminal font issues
  - `python3 -c "import ctypes; libc = ctypes.CDLL('libc.so.6'); 
libc.wcwidth.restype = ctypes.c_int; print(libc.wcwidth(0x1D70B))"` returns `1` 
— glibc considers this a valid, narrow character
  - GNU coreutils `ls` behaviour was not tested as it is no longer available on 
Ubuntu 26.04 without manual intervention
  
  ProblemType: Bug
  DistroRelease: Ubuntu 26.04
  Package: coreutils 9.5-1ubuntu2+0.0.0~ubuntu25
  ProcVersionSignature: Ubuntu 7.0.0-29.29-generic 7.0.12
  Uname: Linux 7.0.0-29-generic x86_64
  ApportVersion: 2.34.1-0ubuntu0.1
  Architecture: amd64
  CasperMD5CheckResult: pass
  CurrentDesktop: XFCE
  Date: Mon Aug 10 00:18:42 2026
  InstallationDate: Installed on 2025-10-28 (285 days ago)
  InstallationMedia: Xubuntu 24.04.1 LTS "Noble Numbat" - Release amd64 
(20240827)
  PackageArchitecture: all
  ProcEnviron:
-  LANG=en_US.UTF-8
-  PATH=(custom, no user)
-  SHELL=/bin/bash
-  TERM=xterm-256color
-  XDG_RUNTIME_DIR=<set>
+  LANG=en_US.UTF-8
+  PATH=(custom, no user)
+  SHELL=/bin/bash
+  TERM=xterm-256color
+  XDG_RUNTIME_DIR=<set>
  SourcePackage: coreutils-from
  UpgradeStatus: Upgraded to resolute on 2026-01-22 (199 days ago)

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

Title:
  `ls` mangles Supplementary Multilingual Plane (SMP) Unicode characters
  when stdout is an SSH pty

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/coreutils-from/+bug/2163129/+subscriptions


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

Reply via email to