This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: Bash 3.1.17(8): Scripts on textmode mount get problems with CR characters


 

-----Original Message-----
>From: Eric Blake 
>Sent: Wednesday, October 25, 2006 8:05 AM
>To: Bruun, Peter Michael 
>Subject: Re: Bash 3.1.17(8): Scripts on textmode mount get problems
with CR characters
>
>-----BEGIN PGP SIGNED MESSAGE-----
>Hash: SHA1
>
>http://cygwin.com/acronyms/#PPIOSPE - redirecting to the list.
>
>According to Bruun, Peter Michael (HP C&I CME OSS CoE) on 10/25/2006
1:18 AM:
>> Hello Eric,
>> 
>> Thanks for the thorough explanation.
>> 
>> Yes, the missing handling of CRLF in `` and $() is the point of my 
>> message - these should understand the igncr setting.
>> 
>> Adding d2u is a cludge - I am working in a cross-platform environment

>> and I do not have d2u on all platforms. I could define it as a dummy 
>> shell-function, but I don't want my Unix scripts to be unnecessarily 
>> polluted by such things. I believe it is an essential part of the 
>> purpose of Cygwin is to hide Windows specific detals, and so having
to 
>> pollute my scripts in this way defies the purpose of Cygwin.
>> 
>> Adding --text to cat is similarly a cludge and would not be portable 
>> to native Unix platforms.
>> 
>> For now, setting IFS sounds like the best option, but as far as I can

>> see, it does not affect command substitution either (at the moment of

>> writing I only have access to bash-3.1-6).
>> 
>> In some contexts I already do white-space normalization using 
>> something like this:
>> 
>> F=`echo \`cat f.txt\``
>> 
>> With IFS set, this will work, but the method is only correct if f.txt

>> does not contain significant white-space other than single blank 
>> characters.
>> 
>> So I am looking forward to bash-3.2-4 with igncr support in command 
>> substitution. When do you think, it will be around?
>
>Yesterday evening.
>
>> 
>> Best regards,
>> 
>> Peter Michael Bruun (HP C&I CME OSS CoE)
>> 



U don't have d2u on all platforms, but U probably _do_ have awk or
gawk on every platform.  I came up with a simple fix for the CRLF
problem when I encountered it, which is still klugy, but works on
every POSIX or Cygwin platform:
   gawk '//' fileFromTextMount > fileWithLFOnlyOnBinMount

I used to use DJGPP in DOS boxes, but it's a DOS port without
awareness of Windows, so when my employer switched from W95/98 to
W2K, I switched to Cygwin, and of course ran in to the CRLF prob-
lem.  I'm a big user of gawk and found that running this simple
script on each script fixed them all.  I wasn't even aware of d2u 
until much later.  Of course, switching to all bin mounts makes 
life a _lot_ easier, too.

There was one issue - which may have been fixed by my latest up-
grade (I still use my workaround, so I'm not sure) - in that run-
ning gawk on files containing binary information sometimes played
games with what gawk thought were line-endings within the binary
data, so I found that if use cat to pipe such files to gawk, the
latter works as expected:
   cat fileFromTextMount | gawk '//' > fileWithLFOnlyOnBinMount

I prefer to change the scripts, because I try to write them to be
portable, but that's just me.  Again, this is a kluge, but it's 
portable.

- -- 
					Thx, Phil Long




--
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/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]