chiark / gitweb /
Note that do_help is used when short messages might be wanted
[topgit.git] / tg.sh
diff --git a/tg.sh b/tg.sh
index 4dcc15eff90bcc581980336b94d44f40e2385759..1fe01155a27bc7e1bfff1de04d68e1dd62ab01ad 100644 (file)
--- a/tg.sh
+++ b/tg.sh
@@ -209,6 +209,12 @@ switch_to_base()
 do_help()
 {
        if [ -z "$1" ] ; then
+               # This is currently invoked in all kinds of circumstances,
+               # including when the user made a usage error. Should we end up
+               # providing more than a short help message, then we should
+               # differentiate.
+               # Petr's comment: http://marc.info/?l=git&m=122718711327376&w=2
+
                ## Build available commands list for help output
 
                cmds=
@@ -232,6 +238,8 @@ do_help()
                fi
        else
                echo "`basename $0`: no help for $1" 1>&2
+               do_help
+               exit 1
        fi
 }
 
@@ -261,7 +269,13 @@ setup_hook "pre-commit"
 [ -z "$tg__include" ] || return 0
 
 if [ "$1" = "-r" ]; then
-       shift; base_remote="$1"; shift
+       shift
+       if [ -z "$1" ]; then
+               echo "Option -r requires an argument." >&2
+               do_help
+               exit 1
+       fi
+       base_remote="$1"; shift
        tg="$tg -r $base_remote"
 fi
 
@@ -279,6 +293,7 @@ help|--help|-h)
 *)
        [ -r "@cmddir@"/tg-$cmd ] || {
                echo "Unknown subcommand: $cmd" >&2
+               do_help
                exit 1
        }
        . "@cmddir@"/tg-$cmd;;