summaryrefslogtreecommitdiff
path: root/bin/common-functions
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2017-10-24 10:27:43 +0200
committerErich Eckner <git@eckner.net>2017-10-24 10:27:43 +0200
commitc3ef246baa587aa1d225320e287e05da315886d3 (patch)
treeafed0dd82b9084f7aeb0488bfb939310910fae90 /bin/common-functions
parentda87aead664b2734aba8afa4d12985907959582c (diff)
downloadbuilder-c3ef246baa587aa1d225320e287e05da315886d3.tar.xz
bin/build-packages: sort content of square brackets in namcap output - hopefully this reduces the count of diff-lines
Diffstat (limited to 'bin/common-functions')
-rwxr-xr-xbin/common-functions50
1 files changed, 50 insertions, 0 deletions
diff --git a/bin/common-functions b/bin/common-functions
index 9cf010b..0ad4b71 100755
--- a/bin/common-functions
+++ b/bin/common-functions
@@ -1045,3 +1045,53 @@ find_biggest_subset_of_packages() {
)
}
+
+# sort_quare_bracket_content $file
+# sort the content of [] in $file, print to stdout
+
+sort_quare_bracket_content() {
+ local file
+ local line
+ local token
+ local token_list
+ local rest
+ file="$1"
+
+ while read -r line; do
+ printf '%s ' "${line}" | \
+ tr ' ' '\n' | \
+ while read -r token; do
+ if echo "${token}" | \
+ grep -qF '['; then
+ printf '%s[' "${token%[*}"
+ token="${token##*[}"
+ token_list="${token%,}"
+ while ! echo "${token_list}" | \
+ grep -qF ']'; do
+ read -r token
+ token_list=$(
+ printf '%s\n' \
+ "${token_list}" \
+ "${token%,}"
+ )
+ done
+ rest="]${token_list#*]}"
+ token_list="${token_list%%]*}"
+ token=$(
+ printf '%s' "${token_list}" | \
+ sort | \
+ sed 's|$|,|'
+ printf '%s' "${rest}"
+ )
+ fi
+ printf '%s\n' "${token}"
+ done | \
+ tr '\n' ' ' | \
+ sed '
+ s|, ]|]|g
+ s| $||
+ '
+ printf '\n'
+ done < \
+ "${file}"
+}