Subject: bug#69718: 29.2; grep japanese-iso-8bit-unix string fails with "grep: illegal byte sequence"

From: Eli Zaretskii <[email-masked]>
Date: Tue, 12 Mar 2024 21:39:03 +0200

> From: Akira Shirai <[email-masked]>
> Date: Wed, 13 Mar 2024 00:42:22 +0900
> Cc: [email-masked],
>  [email-masked]
> 
> emacs-29.1 executes /usr/bin/grep without LANG,
> but emacs-29.2 seems to execute /usr/bin/grep with LANG=en_US.UTF-8.

The fact that LANG could cause this is IMO a bug in macOS's Grep.

There's no problem for Emacs to put LANG into the environment, but
Grep can be invoked on several very different files, with no single
LANG that fits all of them.  Grep should not use LANG at all.

> I wonder /usr/bin/grep should be invoked in non UTF-8 mode, because emacs might pass non UTF-8 byte sequence to /usr/bin/grep.

Illegal byte sequence is not limited to UTF-8.  There really is no
good solution for this, except in Grep itself.  Which is why I don't
think this is an Emacs bug.