From: Oleg Broytman Date: Tue, 12 May 2020 10:49:31 +0000 (+0300) Subject: Get local directory name from origin X-Git-Url: https://git.phdru.name/?a=commitdiff_plain;h=99ebfdfab34769549340fb0cf2050f2f6d430b10;p=git-scripts.git Get local directory name from origin --- diff --git a/clone b/clone index fa51e9f..5d1118d 100755 --- a/clone +++ b/clone @@ -1,12 +1,13 @@ #! /bin/sh -if [ -z "$1" ]; then - echo "Usage: $0 origin" >&2 +if [ -z "$1" -o -n "$3" ]; then + echo "Usage: $0 origin [local]" >&2 exit 1 fi origin="$1" -local_repo="`basename \"$origin\" .git`" +local_repo="$2" +test -z "$local_repo" && local_repo="`basename \"$origin\" .git`" if [ -d "$local_repo"/.git ]; then cd "$local_repo" diff --git a/fork b/fork index 2a537b4..5188356 100755 --- a/fork +++ b/fork @@ -1,13 +1,14 @@ #! /bin/sh -if [ -z "$2" ]; then - echo "Usage: $0 upstream origin" >&2 +if [ -z "$2" -o -n "$4" ]; then + echo "Usage: $0 upstream origin [local]" >&2 exit 1 fi upstream="$1" origin="$2" -local_repo="`basename \"$origin\" .git`" +local_repo="$3" +test -z "$local_repo" && local_repo="`basename \"$origin\" .git`" if [ -d "$local_repo"/.git ]; then cd "$local_repo"