FreeBSD is much like Darwin
[guilt.git] / guilt-select
blob14fd7049ee06bdf51cd5ce5b3598939f5bc849b6
1 #!/bin/sh
3 # Copyright (c) Eric Lesh, 2007
6 USAGE="[ -n | --none | -s | --series | [--pop|--reapply] <guards...> ]"
7 if [ -z "$GUILT_VERSION" ]; then
8 echo "Invoking `basename "$0"` directly is no longer supported." >&2
9 exit 1
12 select_guards()
14 for x in "$@"; do
15 if [ $(printf %s "$x" | grep -e "^[+-]") ]; then
16 die "'$x' cannot begin with + or -."
18 done
19 echo "$@" | sed -e 's/ /\n/g' | sort | uniq > "$guards_file"
22 _main() {
24 if [ $# -eq 0 ]; then
25 if [ -s "$guards_file" ]; then
26 cat "$guards_file"
27 else
28 echo >&2 "No guards applied"
30 exit 0
33 case $1 in
34 -n|--none)
35 rm -f "$guards_file"
37 --pop)
38 guilt-pop -a
39 shift
40 select_guards "$@"
42 --reapply)
43 top=`get_top`
44 guilt-pop -a
45 shift
46 select_guards "$@"
47 guilt-push "$top"
49 -s|--series)
50 (get_full_series | while read patch; do
51 get_guards "$patch"
52 done) | sed -e 's/ /\n/g' | sort | uniq
55 select_guards "$@"
57 esac