summaryrefslogtreecommitdiff
path: root/toolbin/extract_variants
diff options
context:
space:
mode:
authorKatze Miau <miaukatzemiau@priveasy.de>2012-03-02 08:41:04 (GMT)
committerKatze Miau <miaukatzemiau@priveasy.de>2012-03-02 08:41:04 (GMT)
commit61a642235abc3cf0f1297f4f386504a110bd0aa5 (patch)
tree3dadcb773f2d2040d69392cda046f85f127f4ce4 /toolbin/extract_variants
parent754907fd31da80d247432d02128bb4e9c79d31b0 (diff)
add toolbin/merge_config to compose configs and files
toolbin/merge_config takes a list of basenames and merges them by applying them from left to right. If the first basename may refer to a file or a directory; the resulting merge is of the same type. Usage: toolbin/merge_config --merge --dst location [--verbose] base base2 ... For each basename X up to one of three possible files may exist: $X - copy $X as result of the merge (overwritting any existing $X) $X.patch - patch an existing $X $X.delete - delete an existing $X toolbin/extract_variants decomposes a string like foo/bar-baz/boing-bu along the dashes into: foo/bar-baz-boing-bu foo/bar-baz-boing foo/bar-baz foo/bar It is used to generate all possible sources merge_config should consider.
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