{"thread":{"id":"1995","subject":"[PATCH Cogito] Make cg more robust and user friendly","startedAt":"2005-10-02T10:13:06Z","lastAt":"2005-10-02T10:13:06Z","messageCount":1,"participants":["Jonas Fonseca"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"9604","messageId":"20051002101306.GB9219@diku.dk","threadId":"1995","inReplyTo":null,"subject":"[PATCH Cogito] Make cg more robust and user friendly","fromName":"Jonas Fonseca","fromEmail":"fonseca@diku.dk","sentAt":"2005-10-02T10:13:06Z","receivedAt":"2005-10-02T10:13:06Z","isPatch":true,"sender":{"key":"fonseca@diku.dk","avatar":"https://gravatar.com/avatar/f82f3ad698717c51873b020c750a92438c820a24056dc39fe4d07baa10a92264?d=mp&s=160"},"body":"Accept -h in addition to --help. Error out on unknown options. Convert to\nbe a real bash script and slightly simplify the control flow, so we can use\nthe 'type' builtin command for checking if the requested Cogito command\nexists in the PATH.\n\nSigned-off-by: Jonas Fonseca <fonseca@diku.dk>\n\n---\ncommit 5e15803563ef00720541e89ae16a633ac8dfb7d7\ntree 90374bdbc77b04bc5bfa4365e291e3603b0a7099\nparent 20282cdd610ecef03c8c97853bc0749ef3ab32b3\nauthor Jonas Fonseca <fonseca@diku.dk> Thu, 29 Sep 2005 15:12:02 +0200\ncommitter Jonas Fonseca <fonseca@stud1-9.itu.dk> Thu, 29 Sep 2005 15:12:02 +0200\n\n cg |   17 ++++++++++++-----\n 1 files changed, 12 insertions(+), 5 deletions(-)\n\ndiff --git a/cg b/cg\n--- a/cg\n+++ b/cg\n@@ -1,9 +1,16 @@\n-#!/bin/sh\n+#!/usr/bin/env bash\n \n-[ x\"$1\" = \"x\" ] && exec cg-help\n cmd=\"$1\"; shift\n-( [ x\"$cmd\" = x\"--help\" ] ) && exec cg-help\n-( [ x\"$cmd\" = x\"--version\" ] ) && exec cg-version\n+case \"$cmd\" in\n+-h|--help|\"\") cmd=\"help\" ;;\n+--version) cmd=\"version\" ;;\n+-*)\n+\techo \"cg: unknown option '$cmd' (try 'cg --help' or 'cg --version')\" >&2\n+\texit 1\n+esac\n \n exe=\"cg-$cmd\"\n-exec $exe \"$@\"\n+type -P \"$exe\" >/dev/null && exec \"$exe\" \"$@\"\n+\n+echo \"cg: unknown command '$cmd' (try 'cg help')\" >&2\n+exit 1\n\n-- \nJonas Fonseca\n"}]}