rpm-software-management / spec-cleaner

spec-cleaner
BSD 3-Clause "New" or "Revised" License
28 stars 34 forks source link

Line corruption on line with escape characters #263

Closed lgbaldoni closed 4 years ago

lgbaldoni commented 4 years ago

Using spec-cleaner 1.1.5 on Tumbleweed. Giving an old .spec a once over:

sed -i "s|^M||g" README* bwbasic.doc COPYING

gave me this in return:

sed -i "s|
||g" README* bwbasic.doc COPYING

Please let me know if you need the entire file to reproduce this.

scarabeusiv commented 4 years ago

Interestingly when I run it localy with file just containing this line in %install phase it does not break it. Could you please add here the full spec so we can try to minimalize it?

lgbaldoni commented 4 years ago

Here it is bwbasic.spec.gz

scarabeusiv commented 4 years ago

Even with your full file I am unable to reproduce the issue, it does not replace the ^M with newline...

scarabeusiv commented 4 years ago

Actually I can reproduce it, just the diff was not helpful as it seem to replace ^M for the actual action... Meh.

kstreitova commented 4 years ago

Unfortunately, I'm afraid that there is nothing we can do about it. By default, Python translates ^M control character to '\n' (or to '\r' if you set newline option for open() function to ' '). And as different operating systems use different EOL sequences, we just can't simply differentiate if it's a part of the sed command or if it's a proper EOL for e.g. Mac OS.

In this case, I would suggest using dos2unix command instead of sed as a workaround.