Skip to content

Commit

Permalink
Merge pull request #255 from tclahr/replace_ifs
Browse files Browse the repository at this point in the history
refactor: replace for by while
  • Loading branch information
tclahr authored Jul 23, 2024
2 parents f80a179 + f3ef15f commit 86c212a
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 86c212a

Please sign in to comment.