X-Recipient: archive-cygwin AT delorie DOT com DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:reply-to:subject:to:references:from:message-id :date:mime-version:in-reply-to:content-type :content-transfer-encoding; q=dns; s=default; b=yEoYxQDIQGXF8sY+ R7PqLelswfVuxoimSFyInVgeXiz3qiMHA8bd64vBtJIiozxktCFme01tTazidA79 E2/Cled4o5+tFcmMGC3pJtT+tmptPDzZnvKoqffY9alRDYEfcW33Dt4t0UOxrK3B LF0akE8pKk16LUd3p7/adPJJzbI= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:reply-to:subject:to:references:from:message-id :date:mime-version:in-reply-to:content-type :content-transfer-encoding; s=default; bh=7ulgEKC7vtcCM+hpIimtzW fXjvI=; b=gBUYV43Qyq/x81O7ZCpDyefbuLcpDqjASTewVT/MA7TyjI/WQzM/8L KBF9G1NjYdikljS9vL9W2sBJfoLwTWe16jG1SS0BX7oGPfPaOAjJGH0Vbq1FB7SX NCFyj8A5XbduGYb5VzsO2lXQgoVb/9fcrxeOJD0AmyOuD3ZEuazLk= Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com 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,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_DNSWL_LOW autolearn=no version=3.3.2 spammy=H*r:sk:smtp-ou, inglis, Inglis, calgary X-HELO: smtp-out-no.shaw.ca X-Authority-Analysis: v=2.2 cv=a+JAzQaF c=1 sm=1 tr=0 a=MVEHjbUiAHxQW0jfcDq5EA==:117 a=MVEHjbUiAHxQW0jfcDq5EA==:17 a=IkcTkHD0fZMA:10 a=nNlyT0Frw0CBlBNE_yoA:9 a=QEXdDO2ut3YA:10 Reply-To: Brian DOT Inglis AT SystematicSw DOT ab DOT ca Subject: Re: CR-LF handling behavior of SED changed recently - this breaks a lot of MinGW cross build scripts To: cygwin AT cygwin DOT com References: <0F7D3B1B3C4B894D824F5B822E3E5A175B2636E4 AT IRSMSX103 DOT ger DOT corp DOT intel DOT com> <0F7D3B1B3C4B894D824F5B822E3E5A175B26CE47 AT IRSMSX102 DOT ger DOT corp DOT intel DOT com> <65acc4a5-6e8e-2f72-4933-263572dc2631 AT SystematicSw DOT ab DOT ca> <0F7D3B1B3C4B894D824F5B822E3E5A175B270532 AT IRSMSX102 DOT ger DOT corp DOT intel DOT com> <1152474207 DOT 20170609183138 AT yandex DOT ru> <0F7D3B1B3C4B894D824F5B822E3E5A175B2705A7 AT IRSMSX102 DOT ger DOT corp DOT intel DOT com> From: Brian Inglis Message-ID: Date: Sat, 10 Jun 2017 15:09:14 -0600 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.1.1 MIME-Version: 1.0 In-Reply-To: <0F7D3B1B3C4B894D824F5B822E3E5A175B2705A7@IRSMSX102.ger.corp.intel.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-CMAE-Envelope: MS4wfFuHZY/8xzI3nhC8ukg+743wd62gdC5ceCR0At6bbCW4E7wMWZAI0ngIHoSpHoCxrkLDGEgu5OwGDkzM/gWCcn3U4tbucKZptDq84/kAPQrSzKfgd9FD sQM6gvY4m9CCgrj0IQcjNzT6UyxZjokkWXpxTWwMpN/QUmRZiiogECL5Xtk11VOTcOA0JgS2oaR/Uw== X-IsSubscribed: yes On 2017-06-09 10:09, Soegtrop, Michael wrote: >> One could try making a wrapper shell script where sed usually >> lives that adds those options and calls the real sed... > I tried to do exactly this, but I tried to pipe a dos2unix command > in between. It got a bit complicated because I had to parse the sed > command line arguments. The solution of adding an extra command with > -e is much more elegant. And you are right, replacing sed with a > shell script is better than using an alias. There is one issue here with sed, complicating simple aliasing or substitution, requiring a shell function or script be used in the general case. If -e is used, then any inline script argument must be preceded by -e. A simple alias, requiring an inline script argument, would have to be: alias sed='sed -es/\\r\$// -e'. A shell function or script has to examine arguments to see if they are options and if they have arguments, and whether any option is -e, --expression or -f, --file. Options and their arguments are skipped, and if -[ef] is not seen, the next argument is an inline script, and must be preceded by -e. For portable and safe scripts, explicit use of -e before inline script arguments, and -- to end options, before input files, is recommended for that reason. And for makefiles, use SED, and default SED=sed or /bin/sed if not defined. > But the -e method won't work for grep and for awk not in all cases. Then you have to explicitly use tr, sed, or d2u/dos2unix to pre-process Windows input or post-process Windows output. -- Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada -- 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