-#!/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