Bash tool drops non-ASCII characters due to LC_CTYPE=C in shell environment
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 2/5
- Geschätzter Aufwand
- Ein halber Tag
- Anfängerfreundlichkeit
- 72/100
- Issue-Typ
- Bug
- Klarheit
- Klar beschrieben
- Aktivitätsstatus
- Ruhig
- Tech-Stack
- bash
- Bereich
- cli
Rechercherichtung
Beginnen Sie am Einstiegspunkt zum Starten von Subprozessen des bash-Tools und reproduzieren Sie das Problem mit dem gemeldeten Locale, xxd und Befehlen für Pfade mit Nicht-ASCII-Zeichen. Überprüfen Sie, dass die Shell ein UTF-8-Locale erhält und dabei der beabsichtigte minimale Shell-Start erhalten bleibt, und bestätigen Sie anschließend, dass Befehlszeichenfolgen, Dateipfade und geschriebene Inhalte Mehrbytezeichen unverändert bewahren.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Summary
The bash tool in Copilot CLI spawns shells with LANG="" and LC_CTYPE="C". This causes all non-ASCII characters (Chinese, Japanese, Korean, accented Latin, emoji, etc.) to be silently stripped from command strings. File paths containing such characters become unresolvable, and file content written via heredoc or echo loses all multibyte characters.
Environment
- Copilot CLI version: 1.0.49
- OS: macOS (Darwin)
- Shell: bash (spawned by Copilot CLI)
Steps to reproduce
- Open Copilot CLI
- Run any bash command involving non-ASCII characters:
echo "ABC你好DEF" | xxd
Expected: 41 42 43 e4bda0 e5a5bd 44 45 46 0a (UTF-8 bytes preserved)
Actual: 41 42 43 44 45 46 0a — the Chinese characters are gone entirely.
- Attempt to write a file to a path containing non-ASCII directory names:
echo "test" > "/path/to/中文目录/file.txt"
Expected: File created successfully.
Actual: Command hangs indefinitely. The shell appears to attempt resolving a corrupted path (with multibyte characters stripped) and never returns.
Root cause
Running locale inside the bash tool confirms:
LANG=""
LC_COLLATE="C"
LC_CTYPE="C"
LC_MESSAGES="C"
LC_MONETARY="C"
LC_NUMERIC="C"
LC_TIME="C"
LC_ALL=
With LC_CTYPE=C, the shell treats all bytes above 0x7F as invalid and discards them during command-line processing. This affects:
- String literals in commands (echo, printf, heredoc content)
- File path arguments containing non-ASCII characters
- Variable assignments with multibyte content
The same operations succeed when run through Python (which manages its own UTF-8 encoding independent of the shell locale), confirming the filesystem and disk are fine.
Suggested fix
Set LANG=C.UTF-8 (or en_US.UTF-8) when spawning bash subprocesses. This preserves the benefits of a minimal locale (deterministic sort order, no locale-dependent formatting surprises) while correctly handling multibyte characters:
env LANG=C.UTF-8 /bin/bash --norc --noprofile -c "..."
Using --norc --noprofile already avoids loading user shell plugins. Adding a UTF-8 locale on top shouldn't introduce any slowness or side effects.
Impact
This bug makes Copilot CLI effectively unusable for any task involving non-English file paths or content — which is common for users working in CJK languages, or anyone whose project happens to have non-ASCII directory names. The failure mode is particularly bad: commands silently produce corrupted output or hang forever, with no error message indicating the cause.
- Vorherrschende Sprache
- Shell
- Sterne
- 11.2k
- Forks
- 1.9k
- Ø Merge
- 14 Std. 16 Min.
- Gemergte PRs (30 T.)
- 6
Beitragsleitfaden
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus github/copilot-cli
-
triage
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
github/copilot-cli#4848 ·
-
area:agents area:mcp
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
github/copilot-cli#4729 ·
-
area:sessions
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
github/copilot-cli#4712 ·
-
triage
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
github/copilot-cli#4638 ·
-
Expose large_output_file_path on TaskShellProgress so clients can read complete shell-task output Offenarea:tools
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
github/copilot-cli#4630 · 1 Kommentar ·
Alle Issues in github/copilot-cli
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 90/100
danielmiessler/LifeOS#2218 ·
-
docs(agents): strengthen the no-backslash-escaped-backticks rule with an issue-creation example Offen
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 92/100
-
technical-debt
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 85/100
ll7/robot_sf_ll7#9560 ·
-
Update ghgrab to 2.1.0 Offenpackage-update
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
oSoWoSo/vOid_Community_repOsitory#148 · 1 Kommentar ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100