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: Howto set default text file type to DOS/Text under release 1.7 BETA

Niels Hallenberg <nhallenberg <at>> writes:

> I have a lot of scripts that
> won't run under bash as long as the extra CR's are not removed. I know
> of the tool doc2unix, however there are other obstacles too so having
> the auto-conversion is the best solution for me.
> I have also tried to use the extra argument -nocr to bash, however
> that doesn't work either.
> Any ideas?
> Best
> Niels

I too often find it inconvenient that bash won't ignore CRs.  The best fix 
I've found is to put a file "" into /etc/profile.d.  This file 

    (shopt -s igncr) 2>/dev/null && shopt -s igncr # comment is needed if crlf
    export SHELLOPTS

Once this file is in place, shell scripts will ignore CR characters.  I've 
used this solution ever since bash was changed to complain about CR by 
default, and it has worked well for me.

I was going to make some comment about ANSI C/C++ recognising that line 
endings can legitimately be something other than just LF, and text files on 
the system defaulting to CR/LF line endings, and bash shell scripts being text 
files, and cygwin providing useful tools to interoperate with the native OS.  
But then I thought it better to just offer the solution above. :)

Problem reports:
Unsubscribe info:

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