Howto set default text file type to DOS/Text under release 1.7 BETA

View: New views
5 Messages — Rating Filter:   Alert me  

Howto set default text file type to DOS/Text under release 1.7 BETA

by Niels Hallenberg :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I have just installed release 1.7 under Windows 7, 64bit. The
setup.exe program seems to have changed and you can't any longer set
the Default Text File Type to DOS/Text. 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.

After installation, I have the following drives mounted.

$ mount
C:/cygwin/bin on /usr/bin type ntfs (binary,auto)
C:/cygwin/lib on /usr/lib type ntfs (binary,auto)
C:/cygwin on / type ntfs (binary,auto)
C: on /cygdrive/c type ntfs (binary,posix=0,user,noumount,auto)
F: on /cygdrive/f type ntfs (binary,posix=0,user,noumount,auto)
R: on /cygdrive/r type ntfs (binary,posix=0,user,noumount,auto)
U: on /cygdrive/u type ntfs (binary,posix=0,user,noumount,auto)

I can, using the mount-command

$ mount -f -o text,posix=0 c: /cygdrive/c

change the mode to text:

$ mount
C:/cygwin/bin on /usr/bin type ntfs (binary,auto)
C:/cygwin/lib on /usr/lib type ntfs (binary,auto)
C:/cygwin on / type ntfs (binary,auto)
C: on /cygdrive/c type ntfs (text,user)
F: on /cygdrive/f type ntfs (binary,posix=0,user,noumount,auto)
R: on /cygdrive/r type ntfs (binary,posix=0,user,noumount,auto)
U: on /cygdrive/u type ntfs (binary,posix=0,user,noumount,auto)

However, this does not fix the problem and I still get the error:

$ ./foo.sh
./foo.sh: line 1: $'\r': command not found
./foo.sh: line 13: syntax error: unexpected end of file

Here is the script foo.sh:

$ cat foo.sh

# Check that the user supplied one parameter
if [ "$#" != 1 ]
then
  echo "You must supply one parameter:"
  exit 1
fi
# We're done now
exit 0

The error says that there is an extra \r on the first empty line of the script.

I have also tried to use the extra argument -nocr to bash, however
that doesn't work either.

Any ideas?

Best
Niels

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


Re: Howto set default text file type to DOS/Text under release 1.7 BETA

by Larry Hall (Cygwin) :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 10/28/2009 07:59 AM, Niels Hallenberg wrote:
> Hi,
>
> I have just installed release 1.7 under Windows 7, 64bit. The
> setup.exe program seems to have changed and you can't any longer set
> the Default Text File Type to DOS/Text. 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.

<snip>

> I can, using the mount-command
>
> $ mount -f -o text,posix=0 c: /cygdrive/c
>
> change the mode to text:

<snip>

> However, this does not fix the problem and I still get the error:
>
> $ ./foo.sh
> ./foo.sh: line 1: $'\r': command not found
> ./foo.sh: line 13: syntax error: unexpected end of file

<snip>

> Any ideas?

Have you tried all Eric's advice in his bash upgrade announcements?
<http://sourceware.org/ml/cygwin-announce/2009-07/msg00002.html>

--
Larry Hall                              http://www.rfk.com
RFK Partners, Inc.                      (508) 893-9779 - RFK Office
216 Dalton Rd.                          (508) 893-9889 - FAX
Holliston, MA 01746

_____________________________________________________________________

A: Yes.
 > Q: Are you sure?
 >> A: Because it reverses the logical flow of conversation.
 >>> Q: Why is top posting annoying in email?

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


Re: Howto set default text file type to DOS/Text under release 1.7 BETA

by Eric Backus-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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


Re: Howto set default text file type to DOS/Text under release 1.7 BETA

by paul.hermeneutic :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Fri, Oct 30, 2009 at 00:36, Eric Backus <eric_backus@...> wrote:
> 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

Python has implemented a universal line ending scheme.  Perhaps that
could work here.

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


Re: Howto set default text file type to DOS/Text under release 1.7 BETA

by Christopher Faylor-8 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Fri, Oct 30, 2009 at 10:41:08AM -0500, paul.hermeneutic@... wrote:
>On Fri, Oct 30, 2009 at 00:36, Eric Backus <eric_backus@...> wrote:
>>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
>
>Python has implemented a universal line ending scheme.  Perhaps that
>could work here.

That's very unlikely.  We've already rehashed this many times.  Use the
option, fix your files, or use something besides Cygwin's bash.

It really shouldn't be that big a deal.

cgf

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