-
Notifications
You must be signed in to change notification settings - Fork 1
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
base: master
Are you sure you want to change the base?
issue-276 #331
Conversation
<a href="https://github.com/TouchInstinct/BuildScripts/issues/276">issue-276</a> Перед экспортом репозитория проверить файлы на невалидные символы в именах
scripts/export_src.sh
Outdated
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[@]}" |
There was a problem hiding this comment.
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 вроде не надо
scripts/export_src.sh
Outdated
read -d $'\0' err_path | ||
} | ||
|
||
find . -name "*[<>:\\|?*]*" -print0 | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
вот тут я сломался. что тут происходит, куда уходит результат?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Результат читается построчно в функции read_err_path
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
не ну это жесть какая-то. ищем в одной строчке, читаем в функции, а используем вообще дальше
давай попытаемся сделать как в нормальных языках программирования: переменные, зона видимости и вот это всё
scripts/export_src.sh
Outdated
read_err_path() { | ||
read -d $'\0' err_path | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
а нам точно нужна отдельная функция? можем этот код перенести к while?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Вынесено в функцию, чтобы дублирования не было
scripts/export_src.sh
Outdated
do | ||
echo "- $err_path" | ||
done | ||
exit |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exit без кода что вернёт?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Вроде бы то же, что exit 0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Можно exit 1 написать, раз завершение с ошибкой, но разница будет ли
issue-276 Перед экспортом репозитория проверить файлы на невалидные символы в именах