Skip to content

Commit

Permalink
refactor: replace for by while
Browse files Browse the repository at this point in the history
  • Loading branch information
tclahr committed Jul 23, 2024
1 parent f80a179 commit f3ef15f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 19 deletions.
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

0 comments on commit f3ef15f

Please sign in to comment.