delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2006/12/02/09:48:10

X-Spam-Check-By: sourceware.org
To: cygwin AT cygwin DOT com
From: Will Parsons <oudeis AT nodomain DOT invalid>
Subject: Re: bash scripting problem
Date: Sat, 2 Dec 2006 14:47:34 +0000 (UTC)
Lines: 35
Message-ID: <eks3m6$n03$1@sea.gmane.org>
References: <4570BAB1 DOT 1050603 AT qualcomm DOT com> <003401c715b6$a874da50$020aa8c0 AT DFW5RB41>
Reply-To: ellenophilos AT yahoo DOT com
User-Agent: slrn/0.9.8.1 (Debian)
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

Gary R. Van Sickle wrote:
>> From: Rob Walker
>> 
>> d2u may also corrupt "text" files that need to have CR in 
>> them.  This includes bash scripts that need to parse or output CR.
>> 
>> -Rob
>
> Do you have a link to such a script?  I don't mean a proof-of-principle; I'm
> sure a suitable example can be contrived.  What I'm looking for is a shell
> script "in the wild" that purposely has a carriage return embedded in it for
> reasons other than ending a line of the script.
>
Here's a real-life example, slightly edited:

--------------------------
#!/bin/sh

# the first command to sed below contains an embedded '\r', so it may look odd.
sed \
-e 's/
$//'    \
-e 's/^"\(#.*\)"/\1/' \
-e 's/	/,/g' \
-e 's/,,*$//'   \
-e '/^$/d'      \
-e '/^#/s/LLC,200/LLC, 200/' \
$1
--------------------------

This script is used to preprocess the CSV output of Exceed into an ASCII
configuration file used on a Unix-type system (*not* Cygwin).  Note that
the literal <CR> cannot be replaced by "\r" here, since sed doesn't 
support it on this platform.

- Will 


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

- Raw text -


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