Sun 27 Sep 2015 03:58:06 PM UTC, comment #2:
It is true that MSYS programs open text files without doing the CRLF conversion to LF, which is not surprising as they just do like programs on systems which natively uses LF as an EOL.
Anyway all the non-MS programs internally (be it AWK, perl, or C runtimes library) use the LF as a line termination for texts, so on system like MSDos where CRLF is used instead of LF on the file system, there is a CRLF->LF conversion at text input, and LF->CRLF at text output.
However it is still possible to write scripts in a way that they are insensitive to the input EOL style.
For instance look at the following AWK experiment carried out with a MSYS gawk on a DOS console:
The same experiment on an MSYS console:
Now, if I pass RS="\r?\n|\r" to gawk in order to be insensitive to EOL style, then I get for the DOS console:
And this does not change anything for the MSYS console:
If I pass a CRLF EOL in the MSYS console I get the same result:
So, in conclusion, by setting RS="\r?\n|\r" in the BEGIN condition, or passed on the command line, I can make my AWK script EOL insensitive.
The same type of case happens to MSYS Perl.
On a DOS console with an MSYS Perl without doing anything:
On a DOS console with a native Perl without doing anything:
Now, if I set binmode(STDIN,':crlf') (cf perldoc/binmode), then I get with MSYS Perl
But this does not harm the native perl:
Conversely, with only an LF EOL, ie if I do the same experiment under an MSYS console, then I also get, whether it be a native or an MSYS perl, the same good result (no spurious trailing CR):
And the same will occur if I use CRLF under an MSYS console
It will be the same if the EOL is CR:
So, in conclusion, be it perl or any other script (AWK...), the script can be written in a way that it is EOL style insensitive. This way of writing the script is useful not only on MSW, but also if you want to process a source file with non Linux EOL style (MSDOS CRLF, or old MacOS pre-Darwin CR) with a Linux texi2any.
Then, I don't know whether this is a bug or not. I fully agree with Eli's comment, on MSW:
- make sure that all input files are with LF endings (do ``svn propset svn:eol-style LF'' on the input files).
- use MSYS perl, so that we get LF also at output (and do ``svn propset svn:eol-style LF'' also on the output files if they are archived).
This is my prefered way and what I did for latexrefman, however, it is would be also possible to have the native svn:eol-style, and use native perl. That would also work w/o conflicts. So maybe this is a bug...
|