contrib: lsupgrade: optimize output

- Use printf instead of echo for better portability
- Print whole path without reordering components
- Deduplicate code
This commit is contained in:
Matthias Schiffer 2022-01-03 02:46:05 +01:00
parent c0afb9cc39
commit c7e38fdc2c
No known key found for this signature in database
GPG Key ID: 16EF3F64CB201D9C

View File

@ -37,13 +37,12 @@ find ./package packages -name Makefile | grep -v '^packages/packages/' | while r
dirname="$(dirname "$dir" | cut -d/ -f 3-)"
package="$(basename "$dir")"
for file in "${SUFFIX1}"/*; do
echo "${GREEN}$(basename "${file}")${RESET}" "(${BLUE}${repo}${RESET}/${dirname}${dirname:+/}${RED}${package}${RESET}/${SUFFIX1})"
done
for file in "${SUFFIX2}"/*; do
echo "${GREEN}$(basename "${file}")${RESET}" "(${BLUE}${repo}${RESET}/${dirname}${dirname:+/}${RED}${package}${RESET}/${SUFFIX2})"
for file in "${SUFFIX1}"/* "${SUFFIX2}"/*; do
basename="$(basename "${file}")"
suffix="$(dirname "${file}")"
printf "%s\t%s\n" "${basename}" "${BLUE}${repo}${RESET}/${dirname}${dirname:+/}${RED}${package}${RESET}/${suffix}/${GREEN}${basename}${RESET}"
done
popd >/dev/null
done | sort
done | sort | cut -f2-
popd >/dev/null