Implement stable sort (Lacking in POSIX)

This commit is contained in:
root 2013-02-14 00:00:00 +00:00
parent da65f512a7
commit 1e0decc893

View file

@ -40,6 +40,12 @@ isurl() { isnull "${2%%$1://*}"; }
xgrep() { command grep "$@" || : ; }
sort_C() { LC_ALL=C command sort "$@"; }
sort_stable_k2()
{
awk '{ printf("%08d %s\n", NR, $0) }' | sort_C -k3,3 -k1,1 |
awk '{ print $2 " " $3 }'
}
tac() { sed '1!G;h;$!d'; }
# Split $1 into $prefix_:$suffix_
@ -437,8 +443,7 @@ do_push()
$1
EOF
# POSIX compat issue: sort -s (stable), but supported in bsd and gnu
Branchlist=$(xecho "$Branchlist" | sort_C -k2 -s | tac | uniq -s40)
Branchlist=$(xecho "$Branchlist" | sort_stable_k2 | tac | uniq -s40)
TmpPack_Encrypted="$Localdir/tmp_pack_ENCRYPTED_.$$"
TmpObjlist="$Localdir/tmp_packrevlist.$$"