From: R. Steve McKown Date: Fri, 28 Sep 2012 20:27:17 +0000 (-0600) Subject: Fix subdirs create in git, add -y option X-Git-Tag: 0.5~2 X-Git-Url: https://oss.titaniummirror.com/gitweb?p=repo_shell.git;a=commitdiff_plain;h=1a2c51d891dcf3b3d873b355727d925c36f75967 Fix subdirs create in git, add -y option --- diff --git a/scripts/gitcreate b/scripts/gitcreate index 7a46d1b..feef68b 100755 --- a/scripts/gitcreate +++ b/scripts/gitcreate @@ -12,6 +12,12 @@ if [ "$(whoami)" != "$owner" ]; then exit 1 fi +unset yes +if [ "$1" = "-y" ]; then + yes=y + shift +fi + if [ $# -ne 1 ]; then echo "usage: $0 " >&2 exit 1 @@ -25,18 +31,19 @@ fi # Do not create subdirectories without asking first repopath=$(dirname $1) if [ ! -d "$git_root/$repopath" ]; then - echo -n "Create git subdir '$repopath' (y/N)? " - read ans - if [ "$ans" = "y" -o "$ans" = "Y" -o "$ans" = "yes" -o "$ans" = "Yes" \ - -o "$ans" = "YES" ];then - mkdir -p "$git_root/$repopath" 2>/dev/null - if [ ! -d "$git_root/$repopath" ]; then - echo "%0: repository not created, git subdir '$repopath' create failed" >&2 - exit 1 + if [ ! $yes ]; then + echo -n "Create git subdir '$repopath' (y/N)? " + read ans + ans=$(expr "$ans" : '\(.\).*') # works with dash too + if [ "$ans" != "y" -a "$ans" != "Y" ];then + echo "repository creation aborted at user request" + exit 0 fi - else - echo "repository creation aborted at user request" - exit 0 + fi + mkdir -p "$git_root/$repopath" 2>/dev/null + if [ ! -d "$git_root/$repopath" ]; then + echo "%0: repository not created, git subdir '$repopath' create failed" >&2 + exit 1 fi fi