Howto set default text file type to DOS/Text under release 1.7 BETA
Eric Backus
eric_backus@agilent.com
Fri Oct 30 05:36:00 GMT 2009
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?
>
> 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 "igncr.sh" into /etc/profile.d. This file
contains:
(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. :)
--
Eric
--
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
More information about the Cygwin
mailing list