gohugoio / hugo

The world’s fastest framework for building websites.
https://gohugo.io
Apache License 2.0
74.72k stars 7.45k forks source link

Enable color output on recent Windows 10 #8209

Open mchubby opened 3 years ago

mchubby commented 3 years ago

Referencing #4414 and #5344

Recent builds of Windows 10 have Ansi color sequences enabled by default.

Can you change the IsTerminal runtime check in common/terminal/colors.go to allow colors when Windows 10 >= 1909? You could use something like https://github.com/microsoft/hcsshim/blob/master/osversion/osversion_windows.go#L35 and 1909 is 10.0 build 18363 (from [1])

[1] https://docs.microsoft.com/en-us/windows/release-information/

bep commented 3 years ago

We should try to fix this, but I'm not keen on adding that entire windows package, so we should try to figure this out without.

mchubby commented 3 years ago

Well in fact the syscall.GetVersion() may not be the way to go (deprecated), see https://github.com/BishopFox/sliver/issues/108#issuecomment-508057676

It takes a combination of syscall (call to "RtlGetVersion") and unsafe access to retrieve the build value apparently.