From 99ebfdfab34769549340fb0cf2050f2f6d430b10 Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Tue, 12 May 2020 13:49:31 +0300 Subject: [PATCH] Get local directory name from origin --- clone | 7 ++++--- fork | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) 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" -- 2.39.5