# [PATCH Cogito] Make cg more robust and user friendly

1 messages from 2005-10-02 to 2005-10-02. Participants: Jonas Fonseca.
Thread: https://gitlist.dev/t/1995

## Jonas Fonseca, 2005-10-02 10:13

Subject: [PATCH Cogito] Make cg more robust and user friendly
Message-ID: <20051002101306.GB9219@diku.dk>
URL: https://gitlist.dev/e/20051002101306.GB9219%40diku.dk

```
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

```
