File: guilt-select

package info (click to toggle)
guilt 0.36-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 1,312 kB
  • sloc: sh: 3,063; makefile: 95; perl: 42
file content (59 lines) | stat: -rwxr-xr-x 946 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/sh
#
# Copyright (c) Eric Lesh, 2007
#

USAGE="[ -n | --none | -s | --series | [--pop|--reapply] <guards...> ]"
if [ -z "$GUILT_VERSION" ]; then
	echo "Invoking `basename "$0"` directly is no longer supported." >&2
	exit 1
fi

select_guards()
{
	for x in "$@"; do
		if [ $(printf %s "$x" | grep -e "^[+-]") ]; then
			die "'$x' cannot begin with + or -."
		fi
	done
	echo "$@" | sed -e 's/ /\n/g' | sort | uniq > "$guards_file"
}

_main() {

if [ $# -eq 0 ]; then
	if [ -s "$guards_file" ]; then
		cat "$guards_file"
	else
		echo >&2 "No guards applied"
	fi
	exit 0
fi

case $1 in
	-n|--none)
		rm -f "$guards_file"
		;;
	--pop)
		guilt-pop -a
		shift
		select_guards "$@"
		;;
	--reapply)
		top=`get_top`
		guilt-pop -a
		shift
		select_guards "$@"
		guilt-push "$top"
		;;
	-s|--series)
		(get_full_series | while read patch; do
			get_guards "$patch"
		done) | sed -e 's/ /\n/g' | sort | uniq
		;;
	*)
		select_guards "$@"
		;;
esac

}