This is the mail archive of the
mailing list for the Cygwin project.
Re: Howto set default text file type to DOS/Text under release 1.7 BETA
Niels Hallenberg <nhallenberg <at> gmail.com> 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?
I too often find it inconvenient that bash won't ignore CRs. The best fix
I've found is to put a file "igncr.sh" into /etc/profile.d. This file
(shopt -s igncr) 2>/dev/null && shopt -s igncr # comment is needed if crlf
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: http://cygwin.com/problems.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple