Subj : File: writeln() and line endings
To : Nightfox
From : Digital Man
Date : Sat Apr 26 2025 06:26 pm
Re: File: writeln() and line endings
By: Nightfox to Digital Man on Sat Apr 26 2025 01:45 pm
> After this, id_rsa looks fine, but SSH authentication fails (ssh says it
> loads id_rsa but it says "error in libcrypto" and prompts me for a
> password). I've found that the reason seems to be id_rsa has DOS-style line
> endings (with \r\n) - I verified with a hex editor and saw that was indeed
> the case. If I convert id_rsa with dos2unix, I'm able to successfully SSH
> to the other PC.
>
> SlyEdit is writing the lines using the File.writeln() function. I'm running
> my BBS on Linux; should writeln() be expected to write with \n line endings
> on Linux?
On Windows, File.writeln() will append either "\n" or "\r\n" depending on how the file was opened. If it was opened in text mode (the "t" open flag), then "\r\n" is used.
On Linux, the "t" open mode flag is ignored and File.writeln() will always save the text with "\n" appended. Example:
var f = new File("test.blah");
f.open("w");
f.writeln();
Creates a file with a single byte:
$ hd /sbbs/ctrl/test.blah
00000000 0a |.|
00000001
If your edited file is ending up with CRLF terminated lines, that could just be the function of the console.editfile() method (if you're using that) and the underlying C++ methods that post-process the edited the file.
--
digital man (rob)
Breaking Bad quote #7:
[Want another beer?] "Does the Pope shit in his hat?" - Hank Schrader
Norco, CA WX: 54.4�F, 70.0% humidity, 5 mph SW wind, 0.21 inches rain/24hrs
---
� Synchronet � Vertrauen � Home of Synchronet � [vert/cvs/bbs].synchro.net