From c7e38fdc2c29672944ccd00b504ddd86c00bfa41 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Mon, 3 Jan 2022 02:46:05 +0100 Subject: [PATCH] contrib: lsupgrade: optimize output - Use printf instead of echo for better portability - Print whole path without reordering components - Deduplicate code --- contrib/lsupgrade.sh | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/contrib/lsupgrade.sh b/contrib/lsupgrade.sh index 25d10415..284fe44b 100755 --- a/contrib/lsupgrade.sh +++ b/contrib/lsupgrade.sh @@ -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