Mark VY
Mark VY

Reputation: 1673

what locale does grep use if no environment variable explicitly sets it?

In case this is relevant: I'm using Git Bash for Windows but NOT the usual mintty launcher (I'm running bash directly), so I have fewer environment variables set than "normal". In particular, I do not have LC_CTYPE set, which I "normally" would if I were using that launcher.

When I try to run grep -P whatever grep complains that "grep: -P supports only unibyte and UTF-8 locales". Okay, fair. But what locale does it THINK that I have? Let's ask locale.exe what it thinks:

$ locale --version  # check version for sanity
locale (cygwin) 3.4.10
$ locale
locale
LANG=
LC_CTYPE="C.UTF-8"
LC_NUMERIC="C.UTF-8"
LC_TIME="C.UTF-8"
LC_COLLATE="C.UTF-8"
LC_MONETARY="C.UTF-8"
LC_MESSAGES="C.UTF-8"
LC_ALL=

I think I saw in some docs that stuff in "quotes" means that this is a fallback value that locale figured out, rather than something it got directly from the environment... this seems to not be true for the Cygwin version, which prints the above in quotes no matter what I try.

But anyway, C.UTF-8 sure SOUNDS like it should be a UTF-8 locale. And indeed, if I use LC_CTYPE=C.UTF-8 grep -P, then that works fine! So that means that grep has its own ideas about how to figure out what the default locale is. So what ARE those ideas?

Upvotes: 0

Views: 77

Answers (0)

Related Questions