- { for archive in stable testing unstable; do
- # print priority + archive name. priority is in
- # the previous line after finding the archive.
- read -rd '' expression <<EOF ||:
-/o=Debian,a=$archive,.*l=Debian,c=main/{x;s/^ *([-0-9]+).*/\1 $archive/p;q};h
+ local d=$(distro-name)
+ # goto b for archive lines we are interested in, a for lines we arent
+ # print priority + archive name. priority is in
+ # the previous line from the archive line.
+ # case insensitive, because $d is lower and we are matching with first char upper
+ read -rd '' expression <<EOF ||:
+/o=$d/I!b a;/l=$d/I!b a;/c=main/!b a b b;
+: a;s/^ *([-0-9]+).*/\1/;h;b;
+: b;s/^.*a=([^,]+).*/ \1/;H;x;s/\n//;p