| delorie.com/archives/browse.cgi | search |
| X-Recipient: | archive-cygwin AT delorie DOT com |
| X-SWARE-Spam-Status: | No, hits=-2.3 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS |
| X-Spam-Check-By: | sourceware.org |
| To: | cygwin AT cygwin DOT com |
| From: | Eric Backus <eric_backus AT agilent DOT com> |
| Subject: | Re: Howto set default text file type to DOS/Text under release 1.7 BETA |
| Date: | Fri, 30 Oct 2009 05:36:17 +0000 (UTC) |
| Lines: | 35 |
| Message-ID: | <loom.20091030T062617-536@post.gmane.org> |
| References: | <9fffda390910280459y2883a25ag5fbe175eb1552999 AT mail DOT gmail DOT com> |
| Mime-Version: | 1.0 |
| User-Agent: | Loom/3.14 (http://gmane.org/) |
| 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 |
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
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |