resolv.conf and gnupg2
Christian Franke
Christian.Franke@t-online.de
Thu Aug 11 13:36:45 GMT 2022
Andrey Repin wrote:
> Greetings, Christian Franke!
>> ...
>> Unfortunately the ipconfig output is always localized, so this does only
>> work OOTB with English versions of Windows. The ipconfig parsing is also broken due to two reasons:
>> - The current Cygwin versions of awk, grep and sed no longer convert CR/LF
>> -> LF on stdin, so '/FooBar$/' patterns never match.
>> - ipconfig may output scoped IPv6 addresses ("fe80::1%12") which are not matched by the awk script.
>> A draft patch is attached. It also avoids the tmp file and uses shell builtins where possible.
> Why not use netsh with `chcp 65001`?
How would netsh help?
Netsh is also localized and changing the codepage does possibly not
change the output language. Changing the language would also require
'.../en-US/netsh.exe.mui' file which is not necessarily installed.
If netsh is run interactively, it prints a deprecation warning for
'interface' and other commands and recommends usage of powershell.
This works but is slow and might violate local security policy:
powersh()
{
local x
# May require '-ExecutionPolicy ...'
if ! x=$(powershell -NoProfile -Command "$@" 2>/dev/null); then
echo "powershell: failed" >&2
return 1
fi
echo "$x" | tr -d '\r'
}
search=$(powersh \
'Get-DnsClientGlobalSetting `
| ForEach-Object SuffixSearchList')
nameservers=$(powersh \
'Get-DnsClientServerAddress `
| ForEach-Object ServerAddresses `
| select -Unique')
# Alternatively
nameservers=$(powersh \
'Get-NetIPConfiguration `
| ForEach-Object DNSServer `
| ForEach-Object ServerAddresses `
| select -Unique')
...
--
Regards,
Christian
More information about the Cygwin
mailing list