chiark / gitweb /
Don't implement the usage message of tg depend more than once
authorPer Cederqvist <ceder@lysator.liu.se>
Tue, 24 Aug 2010 18:32:38 +0000 (20:32 +0200)
committerUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Tue, 24 Aug 2010 18:38:18 +0000 (20:38 +0200)
The implmentation of "tg depend" had the usage message in two places.
Fixed by creating a usage function, so that there is a single place
to edit if the usage changes.

Signed-off-by: Per Cederqvist <ceder@lysator.liu.se>
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
tg-depend.sh

index e1a6f17..43d8321 100644 (file)
@@ -6,13 +6,18 @@
 name=
 
 
+usage()
+{
+    echo "Usage: tg [...] depend add NAME" >&2
+    exit 1
+}
+
 ## Parse options
 
 subcmd="$1"; shift || :
 case "$subcmd" in
        -h|"")
-               echo "Usage: tg [...] depend add NAME" >&2
-               exit 1;;
+               usage;;
        add)
                ;;
        *)
@@ -23,8 +28,7 @@ while [ -n "$1" ]; do
        arg="$1"; shift
        case "$arg" in
        -*)
-               echo "Usage: tg [...] depend add NAME" >&2
-               exit 1;;
+               usage;;
        *)
                [ -z "$name" ] || die "name already specified ($name)"
                name="$arg";;