aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Deutschmann <whissi@gentoo.org>2019-03-11 04:11:28 +0100
committerThomas Deutschmann <whissi@gentoo.org>2019-03-11 05:56:25 +0100
commit51b5d26d5fddcffc9f89a4e5256c457182bf47c8 (patch)
tree22bdf0ed65e38b5d4e38f18c7a002c7f937fd719
parentMark "unset" action as deprecated (diff)
downloadeselect-rust-51b5d26d.tar.gz
eselect-rust-51b5d26d.tar.bz2
eselect-rust-51b5d26d.zip
find_targets(): sort by version
Signed-off-by: Thomas Deutschmann <whissi@gentoo.org>
-rw-r--r--rust.eselect.in24
1 files changed, 22 insertions, 2 deletions
diff --git a/rust.eselect.in b/rust.eselect.in
index 0ecf87a..311d8c0 100644
--- a/rust.eselect.in
+++ b/rust.eselect.in
@@ -38,12 +38,32 @@ find_missing_broken_symlinks() {
# in "${ENV_D_PATH}/rust" directory
# this function prints list of $pkgname-$pkgver values
find_targets() {
- local f
+ local f fn
local -a providers
+ local -a providers_unsorted
+ local -a providers_sorted
for f in "${ENV_D_PATH}"/rust/provider-*; do
[[ -f ${f} ]] || continue
- providers=("${providers[@]}" "${f##*/provider-}")
+ fn="${f##*/provider-}"
+ if [[ "${fn}" == rust-bin-* ]]; then
+ providers_unsorted+=( "${fn##rust-bin-}-mysortA" )
+ elif [[ "${fn}" == rust-* ]]; then
+ providers_unsorted+=( "${fn##rust-}-mysortZ" )
+ else
+ die -q "Unsupported rust provider file '${f}' found."
+ fi
+ done
+
+ IFS=$'\n' LC_COLLATE=C providers_sorted=( $(sort <<<"${providers_unsorted[*]}") )
+
+ for fn in "${providers_sorted[@]}"; do
+ if [[ "${fn}" == *-mysortA ]]; then
+ providers+=( "rust-bin-${fn%%-mysortA}" )
+ else
+ providers+=( "rust-${fn%%-mysortZ}" )
+ fi
done
+
echo "${providers[@]}"
}