Sample Header Ad - 728x90

`type` command ignores `LANG` after upgrading to `bash` 5.3 on iTerm2/macOS

2 votes
1 answer
214 views
I'm on macOS and I set English as the locale except for LC_TIME:
~ $ locale
LANG="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_CTYPE="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="ja_JP.UTF-8"
LC_ALL=
Previously, the output of type command was (naturally) English:
$ type bash
bash is /opt/homebrew/bin/bash
However, after upgrading to bash 5.3, the output is now in Japanese:
~ $ bash --version
GNU bash, version 5.3.0(1)-release (aarch64-apple-darwin24.4.0)
Copyright (C) 2025 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later 

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

~ $ type bash
bash は /opt/homebrew/bin/bash です
Why? --- By the way, I also have a very surprising result. type command seems NOT to be stateless. Specifically, it seems the command *remember*s the last environment in which it was previously executed:
~ $ echo $LANG
en_US.UTF-8

# The output is in Japanese.
~ $ type bash
bash は /opt/homebrew/bin/bash です

# When I override $LANG, the output is in English.
~ $ LANG= type bash
bash is /opt/homebrew/bin/bash

# As I used *simple command* in bash,
# the value of $LANG is still en_US.UTF-8.
~ $ echo $LANG
en_US.UTF-8

# Now, surprisingly, type outputs in English.
~ $ type bash
bash is /opt/homebrew/bin/bash
--- Current workaround is to use /usr/bin/type instead of the shell builtin type:
~ $ builtin type bash
bash は /opt/homebrew/bin/bash です

~ $ /usr/bin/type bash
bash is /opt/homebrew/bin/bash
--- Output of typeset -p | grep -e LC_ -e LANG (requested by a comment):
~ $ typeset -p | grep -e LC_ -e LANG
declare -x LANG="en_US.UTF-8"
declare -x LC_TERMINAL="iTerm2"
declare -x LC_TERMINAL_VERSION="3.5.14"
declare -x LC_TIME="ja_JP.UTF-8"
Asked by ynn (998 rep)
Jul 8, 2025, 01:09 AM
Last activity: Jul 8, 2025, 08:42 AM