End of line style

A

Alexey Verkhovsky

Sorry for asking a somewhat silly question, but...

If I am working with some Ruby application that has to work from the
same ZIP file on Windows, Linux and OSX, and has to have shebang
comments working out of box on the atter two, what is the right
end-of-line style for such a scenario?

As far as I understand, Ruby itself would handle anything.
As for shebangs, sh on Linux would handle only "\n" and on OSX it would
handle anything (?) and on Windows there is no such concern.

It follows that end-of-line style must be Linux' "\n".

Is that correct?

--
Best regards,

Alexey Verkhovsky

Ruby Forum: http://ruby-forum.org (moderator)
RForum: http://rforum.andreas-s.net (co-author)
Instiki: http://instiki.org (maintainer)
 
F

Florian Gross

Alexey said:
If I am working with some Ruby application that has to work from the
same ZIP file on Windows, Linux and OSX, and has to have shebang
comments working out of box on the atter two, what is the right
end-of-line style for such a scenario?

AFAIK on Windows the shebang is ignored completely unless you are
running in an CGI environment.

Ruby itself does however extract the options from the shebang, I think
it does not care about \n vs. \r\n.

Also in the next version of Ruby trailing carriage returns on ARGV will
AFAIK be ignored.

I think right now it is probably safest to use \n. I'd also convert
newlines to \r\n for the Windows release, though.
 
A

Alexey Verkhovsky

Florian said:
I think right now it is probably safest to use \n. I'd also convert
newlines to \r\n for the Windows release, though.

That would mean a separate release for Windows, which is precisely the
thing that I want to avoid.

A file with \n end-of-lines won't look good in notepad. I don't care
about this. Do you know any other particular reason for having \r\n
end-of-lines for Windows (as in "foo will not work otherwise"), or is it
purely "just because it's Windows-style"?

--
Best regards,

Alexey Verkhovsky

Ruby Forum: http://ruby-forum.org (moderator)
RForum: http://rforum.andreas-s.net (co-author)
Instiki: http://instiki.org (maintainer)
 
F

Florian Gross

Alexey said:
That would mean a separate release for Windows, which is precisely the
thing that I want to avoid.

A file with \n end-of-lines won't look good in notepad. I don't care
about this. Do you know any other particular reason for having \r\n
end-of-lines for Windows (as in "foo will not work otherwise"), or is it
purely "just because it's Windows-style"?

It's because it makes it easier for Windows developers to submit patches
back to you. Just a small point, but if you're going to automate the
whole release process anyway it ought not to be that much trouble to
have newlines of non-binary files converted to \r\n in the Windows
package. (Most software uses .zip archives instead of .tgz for Windows,
anyway.)
 
A

Alexey Verkhovsky

Florian said:
It's because it makes it easier for Windows developers to submit
patches back to you. Just a small point, but if you're going to
automate the whole release process anyway it ought not to be that much
trouble to have newlines of non-binary files converted to \r\n in the
Windows package. (Most software uses .zip archives instead of .tgz for
Windows, anyway.)

I don't know about that - never had any problem submitting patches from
Windows myself. I build them in one of two ways. Either from Cygwin, or
from Eclipse. Both deal with EOL styles transparently. Have you seen
problems of this sort?

Another question: actually, this application (Instiki) is packaged by
Rake::packageTask. Perhaps Rake itself should be a bit smarter about this.

--
Best regards,

Alexey Verkhovsky

Ruby Forum: http://ruby-forum.org (moderator)
RForum: http://rforum.andreas-s.net (co-author)
Instiki: http://instiki.org (maintainer)
 
S

Sam Roberts

Quoteing (e-mail address removed), on Sun, Jan 16, 2005 at 08:23:44PM +0900:
Sorry for asking a somewhat silly question, but...

If I am working with some Ruby application that has to work from the
same ZIP file on Windows, Linux and OSX, and has to have shebang
comments working out of box on the atter two, what is the right
end-of-line style for such a scenario?

As far as I understand, Ruby itself would handle anything.
As for shebangs, sh on Linux would handle only "\n" and on OSX it would
handle anything (?) and on Windows there is no such concern.

OS X is as unix is, the end of line char is NL, chars before are
considered part of the #! command.

Sam
 
F

Florian Gross

Alexey said:
I don't know about that - never had any problem submitting patches from
Windows myself. I build them in one of two ways. Either from Cygwin, or
from Eclipse. Both deal with EOL styles transparently. Have you seen
problems of this sort?

Might depend on editors. Some convert newlines to native format on
saving. (And some don't even understand unix newlines at all meaning you
would have to convert manually.) That would confuse diff quite badly.
(There's the --strip-trailing-cr option, but at least I have to look it
up every time I use it...)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,169
Latest member
ArturoOlne
Top