From: Stephen Rothwell Date: Sat, 29 Sep 2018 03:01:14 +0000 (+1000) Subject: add_repo: make into a /bin/sh script and general style clean up X-Git-Url: https://git.ozlabs.org/?a=commitdiff_plain;h=635ee5cbe72443b9b9b7a1e38e4178193b832d98;p=next-scripts add_repo: make into a /bin/sh script and general style clean up --- diff --git a/add_repo b/add_repo index 98cf1ae..f97551e 100755 --- a/add_repo +++ b/add_repo @@ -1,20 +1,28 @@ -#!/bin/bash +#!/bin/sh -name=$1 -url=$2 -branch=$3 -[[ -z "$name" ]] && { - echo "Need a remote name" 1>&2 +if [ $# -lt 2 ] || [ $# -gt 3 ]; then + printf 'usage: %s []\n' "$0" 1>&2 exit 1 -} -[[ -z "$url" ]] && { - echo "Need a URL" 1>&2 - exit 1 -} -[[ -z "$branch" ]] && branch="master" +fi + +name="$1" +url="$2" +branch="$3" -git remote add --no-tags -t "$branch" "$name" "$url" +if [ -z "$name" ]; then + printf 'Need a remote name\n' 1>&2 + exit 1 +fi +if [ -z "$url" ]; then + printf 'Need a URL\n' 1>&2 + exit 1 +fi +if [ -z "$branch" ]; then + branch='master' +fi -cp .git/config ../etc/git-config +if git remote add --no-tags -t "$branch" "$name" "$url"; then + cp .git/config ../etc/git-config +fi exit 0