Standard linux patch hard-coded only for unix text files.
PS: I do no want convert ALL to unix and then convert result back.
Standard linux patch hard-coded only for unix text files.
PS: I do no want convert ALL to unix and then convert result back.
perl -i.bak -pe's/\R/\n/g' inputfile
to convert any line ending to the standard.
I've run into this problem before a few times. This is what I've discovered:
So this is what I did:
You can use unix2dos to convert patched files back to CRLF line-endings if you want to maintain that convention.
I don't know if this will help, but JavaScript is platform neutral, and achieves such by representing the Windows CRLF and the Unix LF as a single \n character. The software interpreting the JavaScript will automatically convert the \n character to the proper new line character(s) depending upon what OS the software is installed upon. As a result if the patches were formed from a JavaScript function process then it would be OS neutral.
That can be achieved if the JavaScript expects to receive certain raw data as a function argument. This can be achieved in an automated method using PERL to submit the data to the software interpreting the JavaScript in Linux or using one of the various command line shells batched into a file for Windows.
Combined:
dos2unix patchfile.diff
dos2unix $(grep 'Index:' patchfile.diff | awk '{print $2}')
patch --verbose -p0 -i patchfile.diff
unix2dos $(grep 'Index:' patchfile.diff | awk '{print $2}')
The last line depends on whether you want to keep the CRLFs or not.
M.
PS. This should've been a reply to cscrimge's post. DS.