From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21113 invoked by alias); 12 Sep 2017 05:38:12 -0000 Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Received: (qmail 21100 invoked by uid 89); 12 Sep 2017 05:38:11 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.5 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,RCVD_IN_SORBS_SPAM,SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-qt0-f178.google.com Received: from mail-qt0-f178.google.com (HELO mail-qt0-f178.google.com) (209.85.216.178) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 12 Sep 2017 05:38:10 +0000 Received: by mail-qt0-f178.google.com with SMTP id m35so23518271qte.1 for ; Mon, 11 Sep 2017 22:38:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=IZFFRfWBcKlyf44YbJz6skjgxMnp/RmEnXVKbkqz4Lw=; b=aJdsd14CCT3Gf89Tdz7yXbCjHu7GWDyoyEc9oTNTBIiA2Kecse1q+/93s4EeXEi0rg slbzeEjia3nIYAqF8AbS7Or/BDsc/JTf0opLTLvP6hWenb/EpnPEGwNYo8kZ6xAbQPSu cgkl3NbJIi/wbPZK2GiI3zsHUpMzpLD4FIGUqPz3SwCAsxeR8HWcuysUx6K+Drsk/Jgq 8maMsoGcUvoqknXwhw1RkoFpnE1A05FdVLBP6jS5HDNTvEOkAFWSwbm+sjyCV9dLdnCw SVRODq1xu9puewkV1bneK6zlsOad1CBswafpSX/yyz06MZk1hud4NFi/cY0JAmGjYztJ h2NA== X-Gm-Message-State: AHPjjUgxL8rvZlz9d7ZLlq7BkuZkPckfQhfpmyswprBFbr2PbxcHpPFU 6JJ6R/v1HeG6L/00njsvPD3Ik81f6Q== X-Google-Smtp-Source: AOwi7QDI+++k6tt3w6Pi9sQeoojR2WUFjr89LDwUfx3kLNhM3r1e7LfjT8okgmarR+Hu5p/A60ImCl+vlS8PkS41Pmw= X-Received: by 10.237.59.177 with SMTP id r46mr19885698qte.253.1505194688357; Mon, 11 Sep 2017 22:38:08 -0700 (PDT) MIME-Version: 1.0 Received: by 10.140.98.241 with HTTP; Mon, 11 Sep 2017 22:38:07 -0700 (PDT) In-Reply-To: <7ed18312-4929-8299-d186-9cb0aa541a93@redhat.com> References: <7ed18312-4929-8299-d186-9cb0aa541a93@redhat.com> From: Nikolay Melekhin Date: Tue, 12 Sep 2017 05:38:00 -0000 Message-ID: Subject: Re: Extra CR symbol from backticks on Cygwin 2.9.0 To: Eric Blake Cc: cygwin@cygwin.com Content-Type: text/plain; charset="UTF-8" X-SW-Source: 2017-09/txt/msg00133.txt.bz2 Hi Eric, Thanks! This option is what I am looking for. However I cannot agree with you on bash behavior in Cygwin. Section of command substitution in bash documentation says: https://www.gnu.org/software/bash/manual/bash.html#Command-Substitution "...with any trailing newlines deleted." That is why I expected that bash should remove trailing newlines in command substitution results, which are CRLF on Windows. >From my point of view, bash in Cygwin should follow the same rule on Linux and Windows: remove trailing newlines in command substitution. So remove trailing CRLF on Windows. Best regards, Nikolay Melekhin 2017-09-12 1:00 GMT+03:00 Eric Blake : > On 09/11/2017 04:27 PM, Nikolay Melekhin wrote: >> >> I'd expect that Cygwin must remove CRLF symbols from backtick results, > > You expected wrong - by default Cygwin does the same as Linux, which > does NOT remove CR from command substitution (only LF). > >> but remove only LF symbol. It gets different results on Windows and >> Linux. Result on Windows has additional CR symbol and for example >> string comparision, which is working in Linux, fails in Windows. > > It is NOT a bug in Cygwin, but in your failure to sanitize your input. > You'd get the same behavior on Linux if you pass in CR bytes. That said, > >> >> Is any kind of an option/setting which removes such CRs or it is a bug >> in Cygwin? > > Read the release announcements: Cygwin bash DOES have an 'igncr' shell > option (set -o igncr) that does exactly what you are asking for - it > makes bash ignore CR characters in command substitutions and other places: > > https://cygwin.com/ml/cygwin-announce/2017-01/msg00047.html > > The option is not on by default, but exists because it is a common > desire when you can't be bothered to otherwise sanitize CR out of your > input stream. > > -- > Eric Blake, Principal Software Engineer > Red Hat, Inc. +1-919-301-3266 > Virtualization: qemu.org | libvirt.org > -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple