summaryrefslogtreecommitdiff
path: root/tools/hiddenapi/sort_api.sh
diff options
context:
space:
mode:
Diffstat (limited to 'tools/hiddenapi/sort_api.sh')
-rwxr-xr-xtools/hiddenapi/sort_api.sh18
1 files changed, 18 insertions, 0 deletions
diff --git a/tools/hiddenapi/sort_api.sh b/tools/hiddenapi/sort_api.sh
new file mode 100755
index 000000000000..1c6eb1b286b1
--- /dev/null
+++ b/tools/hiddenapi/sort_api.sh
@@ -0,0 +1,18 @@
+#!/bin/bash
+set -e
+if [ -z "$1" ]; then
+ source_list=/dev/stdin
+ dest_list=/dev/stdout
+else
+ source_list="$1"
+ dest_list="$1"
+fi
+# Load the file
+readarray A < "$source_list"
+# Sort
+IFS=$'\n'
+A=( $(LC_COLLATE=C sort -f <<< "${A[*]}") )
+A=( $(uniq <<< "${A[*]}") )
+unset IFS
+# Dump array back into the file
+printf '%s\n' "${A[@]}" > "$dest_list"