Shell-当我使用$ {file [@]}时,等于不起作用

时间:2019-03-11 04:22:45

标签: windows shell

我在Ubuntu上编写了一个代码样式检查器,这项工作很棒。但是现在,我使用Windows 7系统。

在Windows git bash中,我希望文件列表和检查字符串相等,这不好用,我尝试以下代码:

  • 列表文件(/ run_file / test)
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:

您可以查看Checker repository - GitHub

1 个答案:

答案 0 :(得分:0)

我错过的窗口是CRLF,所以这个other sign是换行符(\r)。