Give non-login shells the system locale
/etc/profile.d/locale.sh only runs for login shells, so bash started by SSH or herdr's remote bridge ran in the C locale, where printf emits \u/\U escapes literally instead of the character. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
7633d8dee4
commit
6d7826d635
@@ -16,6 +16,18 @@ export MANPAGER="sh -c 'col -bx | bat -l man -p'"
|
|||||||
# other non-interactive non-login bash sessions still get OMARCHY_PATH.
|
# other non-interactive non-login bash sessions still get OMARCHY_PATH.
|
||||||
[ -r /usr/share/omarchy/default/bash/env-bootstrap ] && . /usr/share/omarchy/default/bash/env-bootstrap
|
[ -r /usr/share/omarchy/default/bash/env-bootstrap ] && . /usr/share/omarchy/default/bash/env-bootstrap
|
||||||
|
|
||||||
|
# /etc/profile.d/locale.sh is what puts /etc/locale.conf into the environment,
|
||||||
|
# and it only runs for login shells. Bash started by SSH or herdr's remote
|
||||||
|
# bridge misses it and lands in the C locale, where printf emits \u/\U escapes
|
||||||
|
# literally instead of the character. Mirror locale.sh for those sessions.
|
||||||
|
if [ -z "${LANG:-}" ]; then
|
||||||
|
[ -r /etc/locale.conf ] && . /etc/locale.conf
|
||||||
|
LANG="${LANG:-C.UTF-8}"
|
||||||
|
export LANG LANGUAGE LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY \
|
||||||
|
LC_MESSAGES LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT \
|
||||||
|
LC_IDENTIFICATION
|
||||||
|
fi
|
||||||
|
|
||||||
case ":$PATH:" in
|
case ":$PATH:" in
|
||||||
*":$HOME/.local/bin:"*) ;;
|
*":$HOME/.local/bin:"*) ;;
|
||||||
*) export PATH="$PATH:$HOME/.local/bin" ;;
|
*) export PATH="$PATH:$HOME/.local/bin" ;;
|
||||||
|
|||||||
Executable
+28
@@ -0,0 +1,28 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
source "$(dirname "$0")/base-test.sh"
|
||||||
|
|
||||||
|
envs="$ROOT/default/bash/envs"
|
||||||
|
|
||||||
|
# Non-login bash (SSH, herdr's remote bridge) never sources
|
||||||
|
# /etc/profile.d/locale.sh, so without this the shell runs in the C locale.
|
||||||
|
lang=$(env -u LANG bash -c 'source "$1"; printf "%s" "$LANG"' bash "$envs")
|
||||||
|
[[ -n $lang ]] || fail "bash env sets a locale when none is inherited"
|
||||||
|
pass "bash env sets a locale when none is inherited"
|
||||||
|
|
||||||
|
[[ ${lang,,} == *utf-8 || ${lang,,} == *utf8 ]] ||
|
||||||
|
fail "bash env picks a UTF-8 locale" "actual: $lang"
|
||||||
|
pass "bash env picks a UTF-8 locale"
|
||||||
|
|
||||||
|
lang=$(LANG=en_DK.UTF-8 bash -c 'source "$1"; printf "%s" "$LANG"' bash "$envs")
|
||||||
|
[[ $lang == "en_DK.UTF-8" ]] || fail "bash env preserves the inherited locale" "actual: $lang"
|
||||||
|
pass "bash env preserves the inherited locale"
|
||||||
|
|
||||||
|
# The symptom that started this: bash only converts \u/\U escapes above 0x7f
|
||||||
|
# when the locale's charset can encode them, so default/bash/aliases prints the
|
||||||
|
# zoxide folder glyph as a literal "\U000F17A9" in the C locale.
|
||||||
|
glyph=$(env -u LANG bash -c 'source "$1"; printf "\U000F17A9"' bash "$envs")
|
||||||
|
[[ $glyph != *'\U'* ]] || fail "bash env locale renders unicode escapes" "actual: $glyph"
|
||||||
|
pass "bash env locale renders unicode escapes"
|
||||||
Reference in New Issue
Block a user