summaryrefslogtreecommitdiff
path: root/toolbin/extract_variants
blob: 84a91c62f2c39495f346382a7daeb4caf2490183 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/bin/bash

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