summaryrefslogtreecommitdiff
path: root/toolbin/extract_variants
diff options
context:
space:
mode:
Diffstat (limited to 'toolbin/extract_variants')
-rwxr-xr-xtoolbin/extract_variants22
1 files changed, 22 insertions, 0 deletions
diff --git a/toolbin/extract_variants b/toolbin/extract_variants
new file mode 100755
index 0000000..9ad52e1
--- /dev/null
+++ b/toolbin/extract_variants
@@ -0,0 +1,22 @@
+#!/bin/sh
+
+print_ext () {
+ ls -d -- "$1"{,.delete,.patch} 2>/dev/null
+}
+
+if [ "$1" == "--ext" ]; then
+ print=print_ext
+ shift
+else
+ print=echo
+fi
+
+(
+ str="$1"
+ while echo "$str" | grep -q -- -; do
+ [ -n "$(print_ext "$str")" ] && $print "$str"
+ str="$(echo "$str" | sed 's/-[^-]*$//')"
+ done
+ [ -n "$(print_ext "$str")" ] && $print "$str"
+) | tac
+
contact: Jan Huwald // Impressum