www.delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2022/08/11/09:38:26

X-Recipient: archive-cygwin AT delorie DOT com
X-Original-To: cygwin AT cygwin DOT com
Delivered-To: cygwin AT cygwin DOT com
DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 413A73858429
Authentication-Results: sourceware.org;
dmarc=none (p=none dis=none) header.from=t-online.de
Authentication-Results: sourceware.org; spf=none smtp.mailfrom=t-online.de
Subject: Re: resolv.conf and gnupg2
To: cygwin AT cygwin DOT com
References: <bbf7534e-ef89-d74c-f897-656a9485bddf AT SystematicSw DOT ab DOT ca>
<61cf96e9-68f9-1186-9c02-61be61614f61 AT t-online DOT de>
<1512349222 DOT 20220810174046 AT yandex DOT ru>
From: Christian Franke <Christian DOT Franke AT t-online DOT de>
Message-ID: <3480b0f8-7b7e-6672-ce8a-ec675eb909a8@t-online.de>
Date: Thu, 11 Aug 2022 15:36:45 +0200
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101
SeaMonkey/2.53.12
MIME-Version: 1.0
In-Reply-To: <1512349222.20220810174046@yandex.ru>
X-TOI-EXPURGATEID: 150726::1660225005-01447F1E-114868A4/0/0 CLEAN NORMAL
X-TOI-MSGID: 5cc96e16-1284-463e-895b-e0c1b8fc1942
X-Spam-Status: No, score=-0.5 required=5.0 tests=BAYES_00, BODY_8BITS,
FREEMAIL_FROM, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, KAM_NUMSUBJECT,
NICE_REPLY_A, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,
SPF_HELO_NONE, SPF_NONE, TXREP,
T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6
X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on
server2.sourceware.org
X-BeenThere: cygwin AT cygwin DOT com
X-Mailman-Version: 2.1.29
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
List-Unsubscribe: <https://cygwin.com/mailman/options/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=unsubscribe>
List-Archive: <https://cygwin.com/pipermail/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-request AT cygwin DOT com?subject=help>
List-Subscribe: <https://cygwin.com/mailman/listinfo/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=subscribe>
Errors-To: cygwin-bounces+archive-cygwin=delorie DOT com AT cygwin DOT com
Sender: "Cygwin" <cygwin-bounces+archive-cygwin=delorie DOT com AT cygwin DOT com>
X-MIME-Autoconverted: from base64 to 8bit by delorie.com id 27BDc7Op027355

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


-- 
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019