public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Christian Franke <Christian.Franke@t-online.de>
To: cygwin@cygwin.com
Subject: Re: resolv.conf and gnupg2
Date: Thu, 11 Aug 2022 15:36:45 +0200	[thread overview]
Message-ID: <3480b0f8-7b7e-6672-ce8a-ec675eb909a8@t-online.de> (raw)
In-Reply-To: <1512349222.20220810174046@yandex.ru>

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


  reply	other threads:[~2022-08-11 13:37 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-09  6:17 Brian Inglis
2022-08-09 12:58 ` Christian Franke
2022-08-09 14:51   ` Lee
2022-08-09 16:07     ` Christian Franke
2022-08-10 14:40   ` Andrey Repin
2022-08-11 13:36     ` Christian Franke [this message]
2022-08-19  9:13       ` Andrey Repin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3480b0f8-7b7e-6672-ce8a-ec675eb909a8@t-online.de \
    --to=christian.franke@t-online.de \
    --cc=cygwin@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).