我在Ubuntu上编写了一个代码样式检查器,这项工作很棒。但是现在,我使用Windows 7系统。
在Windows git bash中,我希望文件列表和检查字符串相等,这不好用,我尝试以下代码:
package co.com.coomeva.golden.service.ws.jms;
import org.springframework.stereotype.Component;
@Component
public class DistributorSender {
private String record;
public void publishMessage(String record) {
this.record = record;
}
}
E:/Code/code.uio
models/test.php,php,js
public/test.php,html,php
代码告诉我rootPath=$(cd `dirname $0`; pwd)
aimPath=`head -1 ${rootPath}/run_file/$1`
cd ${aimPath}
while read -r line
do
if [[ "$line" != "$aimPath" ]]
then
# get file and checker
IFS=',' file=(${line})
for index in "${file[@]}"
do
# skipping this file name
if [[ ${index} = "${file[0]}" ]]; then
continue
fi
if [[ "${index}" = "php" ]]; then
echo "Index Matched"
else
echo "Index is NOT Matched ${index}.ABC"
fi;
if [[ "${index}" = php* ]]; then
echo "Index Matched and has other sign"
else
echo "Index is NOT Matched..."
fi;
done
fi
done < ${rootPath}/run_file/$1
和.ABCIndex is NOT Matched php
为什么Index Matched and has other sign
?我的代码有错误吗?我完全不解。
PS:
答案 0 :(得分:0)
我错过的窗口是CRLF
,所以这个other sign
是换行符(\r
)。