chiark / gitweb /
tg depend: Even more robust subcommand handling
authorPetr Baudis <pasky@suse.cz>
Thu, 25 Sep 2008 13:26:05 +0000 (15:26 +0200)
committerPetr Baudis <pasky@suse.cz>
Thu, 25 Sep 2008 13:26:05 +0000 (15:26 +0200)
tg-depend.sh

index 498eec4..eeb76cd 100644 (file)
@@ -8,12 +8,16 @@ name=
 
 ## Parse options
 
-subcmd="$1"; shift
-[ "$subcmd" = "-h" ] && {
-       echo "Usage: tg [...] depend add NAME" >&2
-       exit 1
-}
-[ "$subcmd" = "add" ] || die "unknown subcommand ($subcmd)"
+subcmd="$1"; shift || :
+case "$subcmd" in
+       -h|"")
+               echo "Usage: tg [...] depend add NAME" >&2
+               exit 1;;
+       add)
+               ;;
+       *)
+               die "unknown subcommand ($subcmd)";;
+esac
 
 while [ -n "$1" ]; do
        arg="$1"; shift