Skip to content
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

refactor: replace for by while #255

Merged
merged 1 commit into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions lib/build_artifact_list.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,13 @@ _build_artifact_list()

# some systems use busybox's find that not always support '-type f'
# skip artifacts that are not applicable to the target operating system
__ba_OIFS="${IFS}"; IFS="
";
for __ba_item in ${__ba_artifact_list}; do
if [ -f "${__ba_item}" ] \
&& { grep -q -E "supported_os:.*all|${__ba_operating_system}" "${__ba_item}" 2>/dev/null || [ "${__UAC_IGNORE_OPERATING_SYSTEM:-false}" = true ]; }; then
echo "${__ba_item}"
fi
done
IFS="${__ba_OIFS}"
# shellcheck disable=SC2162
echo "${__ba_artifact_list}" \
| while read __ba_item || [ -n "${__ba_item}" ]; do
if [ -f "${__ba_item}" ] \
&& { grep -q -E "supported_os:.*all|${__ba_operating_system}" "${__ba_item}" 2>/dev/null || [ "${__UAC_IGNORE_OPERATING_SYSTEM:-false}" = true ]; }; then
echo "${__ba_item}"
fi
done

}
17 changes: 7 additions & 10 deletions lib/list_artifacts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,13 @@ _list_artifacts()
find "${__oa_artifacts_dir}"/* -name "*.yaml" -print 2>/dev/null \
| sed -e "s|^${__oa_artifacts_dir}/||" 2>/dev/null
else
__oa_OIFS="${IFS}"
IFS="
"
__oa_artifacts_tmp=`find "${__oa_artifacts_dir}"/* -name "*.yaml" -print 2>/dev/null`
for __oa_item in ${__oa_artifacts_tmp}; do
if grep -q -E "supported_os:.*all|${__oa_os}" "${__oa_item}" 2>/dev/null; then
echo "${__oa_item}" | sed -e "s|^${__oa_artifacts_dir}/||" 2>/dev/null
fi
done
IFS="${__oa_OIFS}"
# shellcheck disable=SC2162
find "${__oa_artifacts_dir}"/* -name "*.yaml" -print 2>/dev/null \
| while read __oa_item || [ -n "${__oa_item}" ]; do
if grep -q -E "supported_os:.*all|${__oa_os}" "${__oa_item}" 2>/dev/null; then
echo "${__oa_item}" | sed -e "s|^${__oa_artifacts_dir}/||" 2>/dev/null
fi
done
fi
}

Expand Down