aboutsummaryrefslogblamecommitdiff
path: root/Mk/Scripts/plist_sub_sed_sort.sh
blob: c9f6483c28552f94c5bc8d5e2d2555e0f0ab0d8c (plain) (tree)
1
2
3
4
5
6
7
8
9
          




                                                      

               
      







                                                
                                            
#! /bin/sh
#
# MAINTAINER: portmgr@FreeBSD.org
#
# PLIST_SUB_SED helper to sort by longest value first.

set -o pipefail

awk '{
	while (match($0, /s![^!]*![^!]*!g;/)) {
		sedp=substr($0, RSTART, RLENGTH)
		$0=substr($0, RSTART+RLENGTH)
		split(sedp, a, "!")
		# Convert \. to . for sorting.
		gsub(/\\./, ".", a[2])
		print length(a[2]), sedp
	}
}' | sort -rn | awk '{$1=""; print $0}' > $1