【发布时间】:2012-12-29 09:17:19
【问题描述】:
首先我想说我已经阅读了this post,但是我仍然对CR line terminators 有问题。
有一个文件叫build_test.sh,我在leafpad编辑,可以直接在Vim显示:
cp ~/moonbox/llvm-2.9/lib/Transforms/MY_TOOL/$1 test.cpp
cd ~/moonbox/llvm-obj/tools/TEST_TOOL/
make
make install
cd -
但是:
- 使用
cat build_test.sh会输出nothing。 - 使用
more build_test.sh输出:cd - install/llvm-obj/tools/TEST_TOOL/Y_TOOL/$1 test.cpp - 使用
less build_test.sh输出:cp ~/moonbox/llvm-2.9/lib/Transforms/MY_TOOL/$1 test.cpp^Mcd ~/moonbox/llvm-obj/tools/TEST_TOOL/^Mmake^Mmake install^Mcd -
file build_test.sh 的结果是:
build_test.sh: ASCII text, with CR line terminators
在this post 之后,^M 不再存在,但不再有换行符 :-(file build_test_no_cr.sh 的结果现在是:
build_test_nocr.sh: ASCII text, with no line terminators
解决方法可见here。
但是我仍然想知道为什么cat 什么都不显示而more 显示如此奇怪的结果。另外为什么 Vim 中的 dos2unix 和 set fileformat=unix 在这种情况下会失败。
ps:我猜我的编辑器(Vim 或 leafpad?)可能只为换行生成 \r 而不是 \n。怎么会这样?
【问题讨论】: