]> git.ozlabs.org Git - next-scripts/commitdiff
add_repo: make into a /bin/sh script and general style clean up
authorStephen Rothwell <sfr@canb.auug.org.au>
Sat, 29 Sep 2018 03:01:14 +0000 (13:01 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Sat, 29 Sep 2018 03:01:14 +0000 (13:01 +1000)
add_repo

index 98cf1aed341c5325e204110e1e95442a7150c10e..f97551efe311e9524d4ad945e547271f47d8bdd2 100755 (executable)
--- 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 <remote name> <url> [<branch>]\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