From b34587efdacf164141ddea43598102b88206dcb3 Mon Sep 17 00:00:00 2001 From: Varun Chawla Date: Sun, 22 Feb 2026 20:42:00 -0800 Subject: [PATCH] fix: use os.LookupEnv for LANG check in ensureUTF8Env Replace manual string slicing with os.LookupEnv which is more idiomatic and correctly handles the edge case where LANG is set to an empty string. --- v2/internal/frontend/desktop/darwin/clipboard.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/v2/internal/frontend/desktop/darwin/clipboard.go b/v2/internal/frontend/desktop/darwin/clipboard.go index d067e0b64..ffeaa2175 100644 --- a/v2/internal/frontend/desktop/darwin/clipboard.go +++ b/v2/internal/frontend/desktop/darwin/clipboard.go @@ -13,12 +13,10 @@ import ( // an ASCII-compatible encoding that mangles non-ASCII text. func ensureUTF8Env() []string { env := os.Environ() - for _, e := range env { - if len(e) > 5 && e[:5] == "LANG=" { - return env - } + if _, ok := os.LookupEnv("LANG"); !ok { + env = append(env, "LANG=en_US.UTF-8") } - return append(env, "LANG=en_US.UTF-8") + return env } func (f *Frontend) ClipboardGetText() (string, error) {