git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH Cogito] Make cg more robust and user friendly
@ 2005-10-02 10:13 Jonas Fonseca
  0 siblings, 0 replies; only message in thread
From: Jonas Fonseca @ 2005-10-02 10:13 UTC (permalink / raw)
  To: Petr Baudis; +Cc: git

Accept -h in addition to --help. Error out on unknown options. Convert to
be a real bash script and slightly simplify the control flow, so we can use
the 'type' builtin command for checking if the requested Cogito command
exists in the PATH.

Signed-off-by: Jonas Fonseca <fonseca@diku.dk>

---
commit 5e15803563ef00720541e89ae16a633ac8dfb7d7
tree 90374bdbc77b04bc5bfa4365e291e3603b0a7099
parent 20282cdd610ecef03c8c97853bc0749ef3ab32b3
author Jonas Fonseca <fonseca@diku.dk> Thu, 29 Sep 2005 15:12:02 +0200
committer Jonas Fonseca <fonseca@stud1-9.itu.dk> Thu, 29 Sep 2005 15:12:02 +0200

 cg |   17 ++++++++++++-----
 1 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/cg b/cg
--- a/cg
+++ b/cg
@@ -1,9 +1,16 @@
-#!/bin/sh
+#!/usr/bin/env bash
 
-[ x"$1" = "x" ] && exec cg-help
 cmd="$1"; shift
-( [ x"$cmd" = x"--help" ] ) && exec cg-help
-( [ x"$cmd" = x"--version" ] ) && exec cg-version
+case "$cmd" in
+-h|--help|"") cmd="help" ;;
+--version) cmd="version" ;;
+-*)
+	echo "cg: unknown option '$cmd' (try 'cg --help' or 'cg --version')" >&2
+	exit 1
+esac
 
 exe="cg-$cmd"
-exec $exe "$@"
+type -P "$exe" >/dev/null && exec "$exe" "$@"
+
+echo "cg: unknown command '$cmd' (try 'cg help')" >&2
+exit 1

-- 
Jonas Fonseca

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2005-10-02 10:13 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-10-02 10:13 [PATCH Cogito] Make cg more robust and user friendly Jonas Fonseca

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).