编辑:问题的根本原因是 Git autocrlf 设置为 true。 Linux下应该设置为input:
git config --global core.autocrlf input
(原答案)
问题来自 Windows 行尾 (EOL),因此您必须通过 dos2unix(在 Ubuntu 上运行 apt-get install dos2unix)将所有脚本转换为 unix 样式的 EOL,然后转换您的脚本:
dos2unix build/envsetup.sh sdk/bash_completion/adb.bash
然后所有vendorsetup.sh(这将防止您收到“找不到命令”错误):
find device/ -name vendorsetup.sh -exec dos2unix {} \;
最后一个运行choosecombo 脚本:
dos2unix build/core/find-jdk-tools-jar.sh
编辑:为了完成整体编译,详尽的转换:
find . -name '*.sh' -exec dos2unix {} \;
find . -name '*.py' -exec dos2unix {} \;
find . -name '*.c' -exec dos2unix {} \;
find . -name '*.h' -exec dos2unix {} \;
find . -name '*.cpp' -exec dos2unix {} \;
find . -name '*.hpp' -exec dos2unix {} \;
find . -name '*.txt' -exec dos2unix {} \;
find . -name 'Config.in' -exec dos2unix {} \;
find . -name 'Config.src' -exec dos2unix {} \;
find . -name 'Makefile' -exec dos2unix {} \;
find . -name 'mkmakefile' -exec dos2unix {} \;
find . -name 'Kconfig*' -exec dos2unix {} \;
find . -name rmtypedefs -exec dos2unix {} \;
find . -name apicheck -exec dos2unix {} \;
find . -name seapp_contexts -exec dos2unix {} \;
dos2unix external/busybox/scripts/* external/busybox/applets/* kernel/scripts/* dalvik/dx/etc/* prebuilts/sdk/tools/*
*.sh 用于所有 shell 脚本,*.py 用于所有 python 脚本(在 make 编译期间使用),以及 .c 和 .cpp 文件(显然)和 makefile 使用的其他文件。
当然,您可以过度使用find . -type f -exec dos2unix -s -k -o {} \;,让dos2unix 决定哪些文件是文本文件,哪些文件是二进制文件。
可能还有其他的。当我找到新答案时,我会编辑这个答案...