Shell - Когда я использую $ {file [@]} и для, равно не работает - PullRequest
0 голосов
/ 11 марта 2019

Я пишу средство проверки стиля кода в Ubuntu, это хорошая работа.но теперь я использую систему Windows 7.

В Windows Git Bash, я хочу, чтобы список файлов и проверка строки были равны, это плохо работает, я пытаюсь этот код:

  • список файлов (/ run_file / test)
E:/Code/code.uio

models/test.php,php,js
public/test.php,html,php
  • файл проверки (/ run)
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

Почему has other sign?Я код ошибки?Я полностью озадачен.

PS:

Можно посмотреть Checker репозиторий - GitHub

1 Ответ

0 голосов
/ 11 марта 2019

Я скучаю по windows CRLF, так что other sign это разрыв строки (\r).

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...