Log into PS 7.0 on an Ubuntu 18.04 machine:
$PSUICulture
en-US
Returns empty.
Name Value
---- -----
PSVersion 7.0.0
PSEdition Core
GitCommitId 7.0.0
OS Linux 5.0.0-1032-azure #34-Ubuntu SMP Mon Feb 10 19:37:25 UTC 2020
Platform Unix
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0鈥
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
As a data point: In my local Ubuntu 18.04.4 LTS VM, with the latest updates applied, I see a _different kernel_, and I also _don't see the problem you describe_.
Here's the - differing - kernel info from my VM, extracted from $PSVersionTable's outptu:
OS Linux 4.18.0-041800-generic #201808122131 SMP Sun Aug 12 21:33:20 UTC
@mklement0 - interesting.
I was testing using the standard Azure Ubuntu 18.04 marketplace image and had not applied any updates to it.
I first detected the issue occurring in Azure DevOps Pipelines ubuntu-18.04 pipeline images:
https://dev.azure.com/dscottraynsford/GitHub/_build/results?buildId=1431&view=logs&j=1b4c76ef-e880-5241-0155-88566c4dcdab&t=c3b097e0-8d2d-5cef-f943-5ce972a892ac&l=64
The variable returns System.Threading.Thread.CurrentThread.CurrentUICulture.Name.
Docs says:
by default is the same as the operating system culture
So I believe the Ubuntu image have probably an invariant culture like "C".
Good catch, @iSazonov.
The invariant culture's CultureInfo object (examine its properties with [cultureinfo]::InvariantCulture | Format-List) indeed has the empty string as its .Name property value, which is what $PSUICulture (and $PSCulture) reports when the C or POSIX locale is in effect in the calling POSIX-like shell (run locale to check).
# From Bash:
$ LC_ALL=en-US pwsh -noprofile -c '$PSUICulture'
en-US # as expected
$ LC_ALL=C pwsh -noprofile -c '$PSUICulture'
# empty string
$ LC_ALL=POSIX pwsh -noprofile -c '$PSUICulture'
# empty string
The invariant culture's
CultureInfoobject (examine its properties with[cultureinfo] '' | Format-List)
Use [cultureinfo]::InvariantCulture for that (edit or react to this and I'll mark off topic)
Thanks, @SeeminglyScience , I've made the edit, but I'm also curious (happy to mark this as off-topic later):
Did you suggest [cultureinfo]::InvariantCulture solely for conceptual clarity, given that [cultureinfo] '' works too?
The only difference - which I just now realized - is that [cultureinfo] '' creates a _read-write copy_ of the invariant culture. Was that the reason?
Yeah mainly conceptual clarity. It does also create an extra object that isn't needed, and also won't have reference equality with the static instance (neither of these are likely to ever matter though).