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:
- Using
cat build_test.shit outputs nothing. - Using
more build_test.shit outputs:cd - install/llvm-obj/tools/TEST_TOOL/Y_TOOL/$1 test.cpp - Using
less build_test.shit 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
\rterminators 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 themac2unixcommand, which is part of thedos2unixdistribution:This command will not munge files which have already expected line terminators, which is a bonus. And the reverse (
unix2mac) also exists.Note that
mac2unixis the same asdos2unix -c mac.