Documentation: clean up the makefile
[guilt.git] / guilt-guard
blob8cf6b649737c0ec75e7b0cabeebad790281fa6d6
1 #!/bin/sh
3 # Copyright (c) Eric Lesh, 2007
6 USAGE="[-l | --list | -n | --none | [<patchname>] [(+|-)<guard>...]]"
7 if [ -z "$GUILT_VERSION" ]; then
8 echo "Invoking `basename "$0"` directly is no longer supported." >&2
9 exit 1
12 print_guards()
14 guards=`get_guards "$1"`
15 echo "$1: $guards"
18 _main() {
20 if [ "$1" = "-l" -o "$1" = "--list" ]; then
21 get_full_series | while read patch; do
22 print_guards "$patch"
23 done
24 exit 0
25 elif [ "$1" = "-n" -o "$1" = "--none" ]; then
26 patch="$2"
27 if [ -z "$patch" ]; then
28 patch=`get_top`
30 unset_guards "$patch" `get_guards "$patch"`
31 exit 0
34 case $# in
36 if [ ! -s "$applied" ]; then
37 die "No patches applied."
39 print_guards `get_top`
42 if [ -z $(printf %s "$1" | grep -e '^[+-]') ]; then
43 if [ -z $(get_full_series | grep -e "^$1\$") ]; then
44 die "Patch $1 does not exist."
45 else
46 print_guards "$1"
48 else
49 patch=`get_top`
50 if [ -z "$patch" ]; then
51 die "You must specify a patch."
53 unset_guards "$patch" `get_guards "$patch"`
54 set_guards "$patch" "$1"
58 if [ -z $(printf %s "$1" | grep -e '^[+-]') ]; then
59 if [ -z $(get_full_series | grep -e "^$1\$") ]; then
60 die "Patch $1 does not exist."
61 else
62 patch="$1"
64 shift
65 else
66 patch=`get_top`
67 if [ -z "$patch" ]; then
68 die "You must specify a patch."
71 unset_guards "$patch" `get_guards "$patch"`
72 set_guards "$patch" "$@"
74 esac