Firstly I would say that I have read this post however I still have problems for the CR line terminators
.
There is a file called build_test.sh
, I edited in leafpad
and it can be displayed right in Vim
:
cp ~/moonbox/llvm-2.9/lib/Transforms/MY_TOOL/$1 test.cpp
cd ~/moonbox/llvm-obj/tools/TEST_TOOL/
make
make install
cd -
However:
cat build_test.sh
it outputs nothing. more build_test.sh
it outputs:cd - install/llvm-obj/tools/TEST_TOOL/Y_TOOL/$1 test.cpp
less build_test.sh
it outputs: cp ~/moonbox/llvm-2.9/lib/Transforms/MY_TOOL/$1 test.cpp^Mcd ~/moonbox/llvm-obj/tools/TEST_TOOL/^Mmake^Mmake install^Mcd -
The result of file build_test.sh
is:
build_test.sh: ASCII text, with CR line terminators
Following this post, the ^M
no longer exists however there is no more line break :-(
The result of file build_test_no_cr.sh
is now:
build_test_nocr.sh: ASCII text, with no line terminators
The solution can be seen here.
However I still would like why cat
displays nothing and more
displays so odd result. In addition why dos2unix
and set fileformat=unix
in Vim fails for this case.
ps: I guess that maybe my editor(Vim or leafpad?) generates only \r
rather \n
for the newline. How can it be so?
Simple \r
terminators for newlines are "old Mac" line terminators, it is strange that an editor in 2012+ even generates files with such line terminators... Anyway, you can use the mac2unix
command, which is part of the dos2unix
distribution:
# Edits thefile inline
mac2unix thefile
# Takes origfile as an input, outputs to dstfile
mac2unix -n origfile dstfile
This command will not munge files which have already expected line terminators, which is a bonus. And the reverse (unix2mac
) also exists.
Note that mac2unix
is the same as dos2unix -c mac
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With