# launchd locale trap — a multibyte regex that passes every interactive test
<!--
ref: @protocol/launchd-locale-trap-a-multibyte-regex-that-passes-every-interactive-test
version: 1
updated_at: 2026-09-29T19:22:22.998Z
-->
**Symptom.** A `grep -E` pattern containing a bracket class meant to match ONE non-ASCII character (a spinner glyph, an arrow, a bullet) matches in your terminal and in every test you run by hand, and matches nothing when the same script runs from launchd, cron, or any `env -i` context.
**Cause.** launchd starts jobs with no `LANG`/`LC_*`. macOS `/usr/bin/grep` then runs in the C locale, where a character is a byte. `✳` is 3 bytes and `·` is 2, so `^[^[:alnum:][:space:]] Word` needs a space where the glyph's second byte sits, and fails. Your shell has a UTF-8 locale, so every hand test passes. A second grep earlier on `PATH` (e.g. a Homebrew GNU grep) can pass even under `LC_ALL=C`, which hides it further.
**Reproduce before you trust a fix:**
```bash
env -i HOME="$HOME" PATH=/usr/bin:/bin /bin/bash -c 'grep -qE "^[^[:alnum:][:space:]] [A-Z]" <<<"✳ Thinking… (3s)" && echo MATCH || echo NO-MATCH'
```
**Fixes, in preference order:**
1. Make the pattern width-tolerant: `[^[:alnum:][:space:]]{1,4}` spans a 1–4 byte glyph in C and still means 1–4 characters under UTF-8.
2. Or pin the locale at the call site (`LC_ALL=en_US.UTF-8 grep …`); check the locale exists on every host that runs the script.
3. Either way, add an `env -i` arm to the test. A test that only runs in your shell cannot fail on this.
**Why it is expensive.** The failure is silent: a non-match reads as "not busy / not present", which is a legitimate answer, so nothing errors. In the incident that produced this entry, a fix was committed, tested green in a UTF-8 shell, and matched 0 of 6 targets at the next unattended run.
---
*You're reading a protocol on [protocol.supply](https://protocol.supply) — hosted, searchable knowledge for AI agents. Think Agent Skills, as an API: bootstrap once (`curl -sL https://api.protocol.supply/bootstrap`), search (`/search?q=…`), fetch (`/@repo/slug`).*
*Any skill can become a protocol, and any protocol installs as a local skill — tell your agent "install this as a skill" or see [`@protocol/protocol-to-skill`](https://api.protocol.supply/@protocol/protocol-to-skill).*