Changeset View
Changeset View
Standalone View
Standalone View
head/Mk/Scripts/plist_sub_sed_sort.sh
#! /bin/sh | #! /bin/sh | ||||
# $FreeBSD$ | # $FreeBSD$ | ||||
# | # | ||||
# MAINTAINER: portmgr@FreeBSD.org | # MAINTAINER: portmgr@FreeBSD.org | ||||
# | # | ||||
# PLIST_SUB_SED helper to sort by longest value first. | # PLIST_SUB_SED helper to sort by longest value first. | ||||
awk '{ | awk '{ | ||||
while (match($0, /s![^!]*![^!]*!g;/)) { | while (match($0, /s![^!]*![^!]*!g;/)) { | ||||
sedp=substr($0, RSTART, RLENGTH) | sedp=substr($0, RSTART, RLENGTH) | ||||
$0=substr($0, RSTART+RLENGTH) | $0=substr($0, RSTART+RLENGTH) | ||||
split(sedp, a, "!") | split(sedp, a, "!") | ||||
# Convert \. to . for sorting. | # Convert \. to . for sorting. | ||||
gsub(/\\./, ".", a[2]) | gsub(/\\./, ".", a[2]) | ||||
print length(a[2]), sedp | print length(a[2]), sedp | ||||
} | } | ||||
}' | sort -rn | awk '{$1=""; print $0}' | paste -s -d ' ' - | }' | sort -rn | awk '{$1=""; print $0}' > $1 |