Skip to content

issue-276 #331

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

issue-276 #331

wants to merge 5 commits into from

Conversation

rpelmegov
Copy link

issue-276 Перед экспортом репозитория проверить файлы на невалидные символы в именах

<a href="https://github.com/TouchInstinct/BuildScripts/issues/276">issue-276</a> Перед экспортом репозитория проверить файлы на невалидные символы в именах
Comment on lines 50 to 56
ERR_PATH_ARR=($(find . -name "*[<>:\\|?*]*" | xargs -I %s echo "- %s"))
unset IFS

if [ ${#ERR_PATH_ARR[@]} != 0 ]
then
echo "Export aborted! Invalid characters found in file or directories name(s):"
printf "%s\n" "${ERR_PATH_ARR[@]}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

массивы это bash расширение, в чистом sh надо на пустую строку или return code проверять

я предлагаю после вызова find проверить return code или строку на пустоту, потом вывести первую строки, а затем пройтись for по оставшимся результатам, тогда и xargs вроде не надо

read -d $'\0' err_path
}

find . -name "*[<>:\\|?*]*" -print0 |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

вот тут я сломался. что тут происходит, куда уходит результат?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Результат читается построчно в функции read_err_path

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

не ну это жесть какая-то. ищем в одной строчке, читаем в функции, а используем вообще дальше
давай попытаемся сделать как в нормальных языках программирования: переменные, зона видимости и вот это всё

Comment on lines 49 to 51
read_err_path() {
read -d $'\0' err_path
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

а нам точно нужна отдельная функция? можем этот код перенести к while?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Вынесено в функцию, чтобы дублирования не было

do
echo "- $err_path"
done
exit
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exit без кода что вернёт?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Вроде бы то же, что exit 0

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Можно exit 1 написать, раз завершение с ошибкой, но разница будет ли

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants