Subject: how does grep determine locale if no LC environment variables are set

From: <[email-masked]>
Date: Thu, 8 Aug 2024 12:53:08 +0000

I ran into an odd issue... the workaround is easy enough but the issue is weird.
In case this relevant, my grep coms from git bash.  (which I think is mostly Cygwin? (or maybe msys2??))
Anyway, grep -P doesn't work if no LC vars are set, and complains that it only works in unibyte locales or UTF-8.
Normally, the git bash mintty launcher sets LC_CTYPE to en_us.UTF-8 but not if I bypass the launcher and run grep directly.
Here's the weird part, if I ask /usr/bin/locale what LC_TYPE "should" be, it says C.UTF-8.
If I run grep with C.UTF-8 then it also works.  So it must be deriving a default locale an different way.
But how?

Thanks for any pointers.
Mark.

This message is for information purposes only. It is not a recommendation, advice, offer or solicitation to buy or sell a product or service, nor an official confirmation of any transaction. It is directed at persons who are professionals and is intended for the recipient(s) only. It is not directed at retail customers. This message is subject to the terms at: https://www.ib.barclays/disclosures/web-and-email-disclaimer.html. 

For important disclosures, please see: https://www.ib.barclays/disclosures/sales-and-trading-disclaimer.html regarding marketing commentary from Barclays Sales and/or Trading desks, who are active market participants; https://www.ib.barclays/disclosures/barclays-global-markets-disclosures.html regarding our standard terms for Barclays Investment Bank where we trade with you in principal-to-principal wholesale markets transactions; and in respect to Barclays Research, including disclosures relating to specific issuers, see: https://publicresearch.barclays.com.
__________________________________________________________________________________ 
If you are incorporated or operating in Australia, read these important disclosures: https://www.ib.barclays/disclosures/important-disclosures-asia-pacific.html.
__________________________________________________________________________________
For more details about how we use personal information, see our privacy notice: https://www.ib.barclays/disclosures/personal-information-use.html. 
__________________________________________________________________________________