>From 095e13490fa2834d971cefac62d55324ef495471 Mon Sep 17 00:00:00 2001 From: Elias Persson Date: Fri, 13 Jun 2014 10:37:39 +0200 Subject: [PATCH] Avoid endless loop in option parsing and add a --help option. The usage message could probably be better. For now, it's mostly a copy of the scripts doc comment and the comments relating to the options, with structure borrowed from return_disttag.sh. --- get_sources.sh | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/get_sources.sh b/get_sources.sh index 6451bd0..8b3cbf4 100755 --- a/get_sources.sh +++ b/get_sources.sh @@ -16,6 +16,23 @@ if [ -f /etc/centos-git-common ]; then . /etc/centos-git-common fi +usage() { + echo '' + echo "$0 [-h|--help] [--branch BRANCH] [--surl URL]" + echo '' + echo ' -h --help: This help message' + echo ' --branch: Specify branch instead of asking git' + echo ' --surl: Override sources url' + echo '' + echo ' Script to parse the non-text sources metadata file and download' + echo ' the required files from the lookaside cache.' + echo '' + echo ' Please note: this script is non-destructive, it wont replace' + echo ' files that already exist, regardless of their state, allowing you' + echo ' to have work-in-progress content that wont get overwritten.' + exit ${1-1} +} >&2 + #parse command line args BRANCH='' while (($# > 0)) @@ -31,6 +48,12 @@ do surl=$2 shift 2 ;; + -h | --help) + usage 0 + ;; + * ) + usage + ;; esac done -- 1.9.3