delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2020/11/12/11:11:35

X-Recipient: archive-cygwin AT delorie DOT com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CC2B73A4B822
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
s=default; t=1605197447;
bh=O0+MLqTTMEhO7nkxSf9j8IDLOCImtrPve+TLUT0ADKg=;
h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post:
List-Help:List-Subscribe:From:Reply-To:From;
b=nokXgtSmA932BZ6TkS2jF/l2LZTboXDNr14WZDAsGBWO7my7bWmY92CPh8xqAYrSZ
zwr4pg/1dVksjl7aLNUiiTjyVJaQn3vnHDhbVBtsLNVHNcaVP//Uu2AsCqLk/RXrap
FJiH5eYz3yF4yXLxmMo0hgCuxwUNqmdiUBw9++rA=
X-Original-To: cygwin AT cygwin DOT com
Delivered-To: cygwin AT cygwin DOT com
DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 4ACAE386F41D
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20161025;
h=x-gm-message-state:to:from:subject:message-id:date:user-agent
:mime-version:content-language:content-transfer-encoding;
bh=rafUh48zf2p73gncZqNbPi3hNXNCu7LYHenvEU04VA8=;
b=S6KOtVBehFI1Jv51IP6Hl9DH603p9qXveNanIOyD9nbNXYIcYs/lUfClmpo35r76gw
kjyexWo7+n44BMhU/U9mTTvgWPoRMKvyBRoi4a+zFsGqLgyrkxAqCJQEbVeEeS2o6vob
Ejm8PkdQ87Fyr8UELjS3MC0M1skR/WFOOLqGM2+MzsueysSs1vTajknCneyBZ/2PbYjR
xSSewnI0VHL2V4jAjPD2XVLKR5jNBJefRv90N/vSx4VvgTyEYqIv/lye3JYL+Q+PpEIp
oALt/hNmAO1nFMXJbG0wNNhxvLDa/11ENOBpYszT8GQJ71+lq/NUB8bapfeXcFH2JVpK
kXVw==
X-Gm-Message-State: AOAM532NMij99Zv8Q9ZPKz/NxNrdLyIAhqQGEjctzSJrcU98QA9hteqD
sFtK6GZ0dw1hfiGqmVSv3uhQkYF8Daw=
X-Google-Smtp-Source: ABdhPJyUkQ+ucndlvbSUjBELQZ9Bznm6V7wCeisc+IgdalwozG4t0qT4T4JCPWKyE5OCCKzPjha1uQ==
X-Received: by 2002:a05:6512:3485:: with SMTP id
v5mr13107816lfr.181.1605197442396;
Thu, 12 Nov 2020 08:10:42 -0800 (PST)
To: cygwin AT cygwin DOT com
Subject: surrounding double quotes not removed from native command line
arguments when they contain unicode and locale is default
Message-ID: <420b941a-8f6d-29a3-f97d-724025130ce7@gmail.com>
Date: Thu, 12 Nov 2020 19:10:40 +0300
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.4.1
MIME-Version: 1.0
X-Spam-Status: No, score=-1.6 required=5.0 tests=BAYES_00, DKIM_SIGNED,
DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,
SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2
X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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-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>
From: Ilya Basin via Cygwin <cygwin AT cygwin DOT com>
Reply-To: basinilya AT gmail DOT com
Sender: "Cygwin" <cygwin-bounces AT cygwin DOT com>
X-MIME-Autoconverted: from base64 to 8bit by delorie.com id 0ACGBKRZ025143

Hi.
When I launch a Cygwin program from a native Windows program and an argument in the command line string is quoted and contains national characters then the Cygwin program behaves as if double quotes were part of the program argument.
This happens if I don't explicitly set LC_ALL or if I set LC_ALL=C or set LC_ALL=C.UTF-8

This is a problem because arguments with spaces must be quoted.

If I set the locale to some language and country the quotes are removed as expected no matter what code page I use, UTF-8 or a single-byte code page. The locale doesn't have to match the alphabet used.

If the argument is not quoted or if it doesn't contain national characters then it works even with the C locale.

    C:\>set LC_ALL=
    
    C:\>C:/cygwin/bin/ls -l C:/test-z-я/some.txt
    -rw-r--r-- 1 il None 0 Nov 12 09:52 'C:/test-z-'$'/321/217''/some.txt'
    
    C:\>C:/cygwin/bin/ls -l "C:/test-z-я/some.txt"
    /usr/bin/ls: cannot access '"C:/test-z-'$'\321\217''/some.txt"': No such file or directory
    
    C:\>C:/cygwin/bin/ls -l "C:/test-z-Z/some.txt"
    -rw-r--r-- 1 il None 0 Nov 12 09:52 C:/test-z-Z/some.txt
    
    C:\>C:\cygwin\bin\locale
    LANG=
    LC_CTYPE="C.UTF-8"
    LC_NUMERIC="C.UTF-8"
    LC_TIME="C.UTF-8"
    LC_COLLATE="C.UTF-8"
    LC_MONETARY="C.UTF-8"
    LC_MESSAGES="C.UTF-8"
    LC_ALL=
    
    C:\>set LC_ALL=C.UTF-8
    
    C:\>C:/cygwin/bin/ls -l "C:/test-z-я/some.txt"
    /usr/bin/ls: cannot access '"C:/test-z-я/some.txt"': No such file or directory
    
    C:\>set LC_ALL=en_US.CP1252
    
    C:\>C:/cygwin/bin/ls -l "C:/test-z-я/some.txt"
    -rw-r--r-- 1 il None 0 Nov 12 09:52 'C:/test-z-'$'/030''N'$'/217''/some.txt'
    
    C:\>set LC_ALL=en_US.UTF-8
    
    C:\>C:/cygwin/bin/ls -l "C:/test-z-я/some.txt"
    -rw-r--r-- 1 il None 0 Nov 12 09:52 'C:/test-z-я/some.txt'
    
--
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