forked from kiss-community/kiss
kiss: Remove need for external sort of extension list
This commit is contained in:
parent
e9fbcc6f13
commit
2c19349a09
17
kiss
17
kiss
@ -1475,14 +1475,25 @@ args() {
|
|||||||
# see [1] at top of script.
|
# see [1] at top of script.
|
||||||
set -- $(KISS_PATH=$PATH pkg_find kiss-\* all -x)
|
set -- $(KISS_PATH=$PATH pkg_find kiss-\* all -x)
|
||||||
|
|
||||||
for path do
|
# To align descriptions figure out which extension has the longest
|
||||||
p=${path#*/kiss-} max=$((${#p} > max ? ${#p}+1 : max))
|
# name by doing a simple 'name > max ? name : max' on the basename
|
||||||
|
# of the path with 'kiss-' stripped as well.
|
||||||
|
#
|
||||||
|
# This also removes any duplicates found in '$PATH', picking the
|
||||||
|
# first match.
|
||||||
|
for path do p=${path#*/kiss-}
|
||||||
|
case " $seen " in
|
||||||
|
*" $p "*) shift ;;
|
||||||
|
*) seen=" $seen $p " max=$((${#p} > max ? ${#p}+1 : max))
|
||||||
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# Print each extension, grab its description from the second line
|
||||||
|
# in the file and align the output based on the above max.
|
||||||
for path do
|
for path do
|
||||||
printf "%b->%b %-${max}s " "$lcol" "$lclr" "${path#*/kiss-}"
|
printf "%b->%b %-${max}s " "$lcol" "$lclr" "${path#*/kiss-}"
|
||||||
sed -n 's/^# *//;2p' "$path"
|
sed -n 's/^# *//;2p' "$path"
|
||||||
done | sort -uk1 >&2
|
done >&2
|
||||||
;;
|
;;
|
||||||
|
|
||||||
*)
|
*)
|
||||||
|
Loading…
Reference in New Issue
Block a user