Default line endings on Mac

classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|

Default line endings on Mac

apjanke-floss
Hi, Octave maintainers,

On macOS, at least with a Qt build, the default EOL mode for Octave as
of 4.4.1 is "Mac (CR)".

I think this might be an archaism: "Mac" (\r) EOL mode text files were
used by pre-OS X Mac OSes like Mac OS 9. Since the switch to the
Unix-based OS X, Mac programs generally default to Unix style (\n) line
endings. You can verify this by opening TextEdit and creating a new
plain text file: it uses \n EOLs.

Having files created in legacy Mac (\r) mode makes it a bit harder to
use Unix command line tools and stuff like GitHub with those files.

Can/should Octave be changed to default to Unix (\n) EOLs on macOS?

Cheers,
Andrew

Reply | Threaded
Open this post in threaded view
|

Re: Default line endings on Mac

John W. Eaton
Administrator
On 1/10/19 12:54 PM, Andrew Janke wrote:

> Hi, Octave maintainers,
>
> On macOS, at least with a Qt build, the default EOL mode for Octave as
> of 4.4.1 is "Mac (CR)".
>
> I think this might be an archaism: "Mac" (\r) EOL mode text files were
> used by pre-OS X Mac OSes like Mac OS 9. Since the switch to the
> Unix-based OS X, Mac programs generally default to Unix style (\n) line
> endings. You can verify this by opening TextEdit and creating a new
> plain text file: it uses \n EOLs.
>
> Having files created in legacy Mac (\r) mode makes it a bit harder to
> use Unix command line tools and stuff like GitHub with those files.
>
> Can/should Octave be changed to default to Unix (\n) EOLs on macOS?

If that is what is currently used by default on macos by other
applications then I think we should switch.  We would, of course, still
support files with CR line endings, but create new files with LF.

Do we currently detect the line endings in the file and try to match the
usage?  If not, should we?  How difficult would it be?

Now, if Windows would just abandon CRLF in favor of LF only...

jwe

Reply | Threaded
Open this post in threaded view
|

Re: Default line endings on Mac

Torsten-3
In reply to this post by apjanke-floss
On 10.01.19 18:54, Andrew Janke wrote:

> Hi, Octave maintainers,
>
> On macOS, at least with a Qt build, the default EOL mode for Octave as
> of 4.4.1 is "Mac (CR)".
>
> I think this might be an archaism: "Mac" (\r) EOL mode text files were
> used by pre-OS X Mac OSes like Mac OS 9. Since the switch to the
> Unix-based OS X, Mac programs generally default to Unix style (\n) line
> endings. You can verify this by opening TextEdit and creating a new
> plain text file: it uses \n EOLs.
>
> Having files created in legacy Mac (\r) mode makes it a bit harder to
> use Unix command line tools and stuff like GitHub with those files.
>
> Can/should Octave be changed to default to Unix (\n) EOLs on macOS?
>
> Cheers,
> Andrew
>

If Mac users agree to LF being the default ending, the change should not
be difficult. Btw: In Geany, the line ending CR is denoted as "Classic
Mac", which might be more up to date.

Torsten


Reply | Threaded
Open this post in threaded view
|

Re: Default line endings on Mac

Torsten-3
In reply to this post by John W. Eaton
On 10.01.19 19:57, John W. Eaton wrote:

> On 1/10/19 12:54 PM, Andrew Janke wrote:
>> Hi, Octave maintainers,
>>
>> On macOS, at least with a Qt build, the default EOL mode for Octave as
>> of 4.4.1 is "Mac (CR)".
>>
>> I think this might be an archaism: "Mac" (\r) EOL mode text files were
>> used by pre-OS X Mac OSes like Mac OS 9. Since the switch to the
>> Unix-based OS X, Mac programs generally default to Unix style (\n)
>> line endings. You can verify this by opening TextEdit and creating a
>> new plain text file: it uses \n EOLs.
>>
>> Having files created in legacy Mac (\r) mode makes it a bit harder to
>> use Unix command line tools and stuff like GitHub with those files.
>>
>> Can/should Octave be changed to default to Unix (\n) EOLs on macOS?
>
> If that is what is currently used by default on macos by other
> applications then I think we should switch.  We would, of course, still
> support files with CR line endings, but create new files with LF.
>
> Do we currently detect the line endings in the file and try to match the
> usage?  If not, should we?  How difficult would it be?
>
> Now, if Windows would just abandon CRLF in favor of LF only...
>
> jwe
>

The eol mode is detecting while loading the file into the editor. Then,
I will change the default on Mac to LF.

Torsten


Reply | Threaded
Open this post in threaded view
|

Aw: Re: Default line endings on Mac

mmuetzel
In reply to this post by John W. Eaton
Am Donnerstag, 10. Januar 2019 um 19:57 Uhr schrieb "John W. Eaton":

> On 1/10/19 12:54 PM, Andrew Janke wrote:
> > Hi, Octave maintainers,
> >
> > On macOS, at least with a Qt build, the default EOL mode for Octave as
> > of 4.4.1 is "Mac (CR)".
> >
> > I think this might be an archaism: "Mac" (\r) EOL mode text files were
> > used by pre-OS X Mac OSes like Mac OS 9. Since the switch to the
> > Unix-based OS X, Mac programs generally default to Unix style (\n) line
> > endings. You can verify this by opening TextEdit and creating a new
> > plain text file: it uses \n EOLs.
> >
> > Having files created in legacy Mac (\r) mode makes it a bit harder to
> > use Unix command line tools and stuff like GitHub with those files.
> >
> > Can/should Octave be changed to default to Unix (\n) EOLs on macOS?
>
> If that is what is currently used by default on macos by other
> applications then I think we should switch.  We would, of course, still
> support files with CR line endings, but create new files with LF.
The attached patch should change the default EOL to LF for Mac.
But I don't have a Mac to check if it actually works.

> Do we currently detect the line endings in the file and try to match the
> usage?  If not, should we?  How difficult would it be?

I believe such a check is already done in file_editor_tab::detect_eol_mode.

> Now, if Windows would just abandon CRLF in favor of LF only...

I hear you. And UTF-8 as a working encoding. Or better yet the default...

Markus

EOL_Mac.patch (2K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Default line endings on Mac

apjanke-floss
In reply to this post by Torsten-3

On 1/10/19 2:02 PM, Torsten wrote:

> On 10.01.19 18:54, Andrew Janke wrote:
>> Hi, Octave maintainers,
>>
>> On macOS, at least with a Qt build, the default EOL mode for Octave as
>> of 4.4.1 is "Mac (CR)".
>>
>> I think this might be an archaism: "Mac" (\r) EOL mode text files were
>> used by pre-OS X Mac OSes like Mac OS 9. Since the switch to the
>> Unix-based OS X, Mac programs generally default to Unix style (\n) line
>> endings. You can verify this by opening TextEdit and creating a new
>> plain text file: it uses \n EOLs.
>>
>> Having files created in legacy Mac (\r) mode makes it a bit harder to
>> use Unix command line tools and stuff like GitHub with those files.
>>
>> Can/should Octave be changed to default to Unix (\n) EOLs on macOS?
>>
>> Cheers,
>> Andrew
>>
>
> If Mac users agree to LF being the default ending, the change should not
> be difficult. Btw: In Geany, the line ending CR is denoted as "Classic
> Mac", which might be more up to date.
>
> Torsten
>

I like the "Classic Mac" labeling. That seems more informative.

Some other data points:

Sublime Text denotes it as "Mac OS 9".
BBEdit denotes it as "Legacy Mac (CR)".
TextEdit and Atom don't seem to have any controls for selecting the EOL
format.
Matlab R2018b doesn't seem to have a setting for it, but creates new
files in Unix (LF) format.

Andrew

Reply | Threaded
Open this post in threaded view
|

Re: Aw: Re: Default line endings on Mac

Torsten-3
In reply to this post by mmuetzel
On 10.01.19 20:21, "Markus Mützel" wrote:

> Am Donnerstag, 10. Januar 2019 um 19:57 Uhr schrieb "John W. Eaton":
>> On 1/10/19 12:54 PM, Andrew Janke wrote:
>>> Hi, Octave maintainers,
>>>
>>> On macOS, at least with a Qt build, the default EOL mode for Octave as
>>> of 4.4.1 is "Mac (CR)".
>>>
>>> I think this might be an archaism: "Mac" (\r) EOL mode text files were
>>> used by pre-OS X Mac OSes like Mac OS 9. Since the switch to the
>>> Unix-based OS X, Mac programs generally default to Unix style (\n) line
>>> endings. You can verify this by opening TextEdit and creating a new
>>> plain text file: it uses \n EOLs.
>>>
>>> Having files created in legacy Mac (\r) mode makes it a bit harder to
>>> use Unix command line tools and stuff like GitHub with those files.
>>>
>>> Can/should Octave be changed to default to Unix (\n) EOLs on macOS?
>>
>> If that is what is currently used by default on macos by other
>> applications then I think we should switch.  We would, of course, still
>> support files with CR line endings, but create new files with LF.
>
> The attached patch should change the default EOL to LF for Mac.
> But I don't have a Mac to check if it actually works.
>
>> Do we currently detect the line endings in the file and try to match the
>> usage?  If not, should we?  How difficult would it be?
>
> I believe such a check is already done in file_editor_tab::detect_eol_mode.
>
>> Now, if Windows would just abandon CRLF in favor of LF only...
>
> I hear you. And UTF-8 as a working encoding. Or better yet the default...
>
> Markus
>

Markus, the patch looks good. However, I can't test it either.

Torsten


Reply | Threaded
Open this post in threaded view
|

Re: Aw: Re: Default line endings on Mac

apjanke-floss


On 1/10/19 2:45 PM, Torsten wrote:

> On 10.01.19 20:21, "Markus Mützel" wrote:
>> Am Donnerstag, 10. Januar 2019 um 19:57 Uhr schrieb "John W. Eaton":
>>
>> The attached patch should change the default EOL to LF for Mac.
>> But I don't have a Mac to check if it actually works.
>>
>>> Do we currently detect the line endings in the file and try to match the
>>> usage?  If not, should we?  How difficult would it be?
>>
>> I believe such a check is already done in file_editor_tab::detect_eol_mode.
>>
>>> Now, if Windows would just abandon CRLF in favor of LF only...
>>
>> I hear you. And UTF-8 as a working encoding. Or better yet the default...
>>
>> Markus
>>
>
> Markus, the patch looks good. However, I can't test it either.
>
> Torsten

I tested the patch on macOS 10.13.6 and it looks good. After blowing away my
~/.config/octave to get a clean slate, it defaulted to using Unix (LF)
as the line ending format.

Cheers,
Andrew

Reply | Threaded
Open this post in threaded view
|

Re: Aw: Re: Default line endings on Mac

Torsten-3
On 10.01.19 20:50, Andrew Janke wrote:

>
>
> On 1/10/19 2:45 PM, Torsten wrote:
>> On 10.01.19 20:21, "Markus Mützel" wrote:
>>> Am Donnerstag, 10. Januar 2019 um 19:57 Uhr schrieb "John W. Eaton":
>>>
>>> The attached patch should change the default EOL to LF for Mac.
>>> But I don't have a Mac to check if it actually works.
>>>
>>>> Do we currently detect the line endings in the file and try to match
>>>> the
>>>> usage?  If not, should we?  How difficult would it be?
>>>
>>> I believe such a check is already done in
>>> file_editor_tab::detect_eol_mode.
>>>
>>>> Now, if Windows would just abandon CRLF in favor of LF only...
>>>
>>> I hear you. And UTF-8 as a working encoding. Or better yet the
>>> default...
>>>
>>> Markus
>>>
>>
>> Markus, the patch looks good. However, I can't test it either.
>>
>> Torsten
>
> I tested the patch on macOS 10.13.6 and it looks good. After blowing
> away my
> ~/.config/octave to get a clean slate, it defaulted to using Unix (LF)
> as the line ending format.
>
> Cheers,
> Andrew
>

Andrew, thanks for testing.
Markus, could you then please push your patch?

Torsten

Reply | Threaded
Open this post in threaded view
|

Re: Re: Default line endings on Mac

mmuetzel
On 10. Januar 2019 Torsten wrote:

> On 10.01.19 20:50, Andrew Janke wrote:
> > I tested the patch on macOS 10.13.6 and it looks good. After blowing
> > away my
> > ~/.config/octave to get a clean slate, it defaulted to using Unix (LF)
> > as the line ending format.
> >
> > Cheers,
> > Andrew
> >
>
> Andrew, thanks for testing.
> Markus, could you then please push your patch?

To stable or to default?

Markus

Reply | Threaded
Open this post in threaded view
|

Re: Default line endings on Mac

Torsten-3
On 10.01.19 23:17, "Markus Mützel" wrote:

> On 10. Januar 2019 Torsten wrote:
>> On 10.01.19 20:50, Andrew Janke wrote:
>>> I tested the patch on macOS 10.13.6 and it looks good. After blowing
>>> away my
>>> ~/.config/octave to get a clean slate, it defaulted to using Unix (LF)
>>> as the line ending format.
>>>
>>> Cheers,
>>> Andrew
>>>
>>
>> Andrew, thanks for testing.
>> Markus, could you then please push your patch?
>
> To stable or to default?
>
> Markus
>

If no one else has objections I suggest to push it to stable. It is a
quite small change in the code but it affects the default behavior for
which a new major release is a very good occasion.

Torsten


Reply | Threaded
Open this post in threaded view
|

Re: Default line endings on Mac

apjanke-floss


On 1/11/19 12:27 AM, Torsten wrote:

> On 10.01.19 23:17, "Markus Mützel" wrote:
>> On 10. Januar 2019 Torsten wrote:
>>> On 10.01.19 20:50, Andrew Janke wrote:
>>>> I tested the patch on macOS 10.13.6 and it looks good. After blowing
>>>> away my
>>>> ~/.config/octave to get a clean slate, it defaulted to using Unix (LF)
>>>> as the line ending format.
>>>>
>>>> Cheers,
>>>> Andrew
>>>>
>>>
>>> Andrew, thanks for testing.
>>> Markus, could you then please push your patch?
>>
>> To stable or to default?
>>
>> Markus
>>
>
> If no one else has objections I suggest to push it to stable. It is a
> quite small change in the code but it affects the default behavior for
> which a new major release is a very good occasion.
>
> Torsten
>

I support this. It's a low-risk change, and I think you're right; a
major release is a good time for it.

Andrew

Reply | Threaded
Open this post in threaded view
|

Re: Default line endings on Mac

mmuetzel
Am Freitag, 11. Januar 2019 um 06:34 Uhr schrieb "Andrew Janke":

> On 1/11/19 12:27 AM, Torsten wrote:
> > On 10.01.19 23:17, "Markus Mützel" wrote:
> >> On 10. Januar 2019 Torsten wrote:
> >>> On 10.01.19 20:50, Andrew Janke wrote:
> >>>> I tested the patch on macOS 10.13.6 and it looks good. After blowing
> >>>> away my
> >>>> ~/.config/octave to get a clean slate, it defaulted to using Unix (LF)
> >>>> as the line ending format.
> >>>>
> >>>> Cheers,
> >>>> Andrew
> >>>>
> >>>
> >>> Andrew, thanks for testing.
> >>> Markus, could you then please push your patch?
> >>
> >> To stable or to default?
> >>
> >> Markus
> >>
> >
> > If no one else has objections I suggest to push it to stable. It is a
> > quite small change in the code but it affects the default behavior for
> > which a new major release is a very good occasion.
> >
> > Torsten
> >
>
> I support this. It's a low-risk change, and I think you're right; a
> major release is a good time for it.
>
> Andrew
>

I pushed the patch to stable here:
https://hg.savannah.gnu.org/hgweb/octave/rev/80e69933b6c0

Markus