- "$@"
- leave
- verbose "run end"
- exit 0
-
-#elif [ "$1" = 'use' ]; then
-# verbose "use begin"
-# if [ -n "$ZSH_VERSION" ]; then
-# if [ -o NO_IGNORE_EOF ]; then
-# export VCSH_NO_IGNORE_EOF=1
-# setopt IGNORE_EOF
-# fi
-# vcsh_exit() {
-# vcsh exit;
-# zle reset-prompt;
-# }
-# zle -N vcsh_exit
-# bindkey '^d' 'vcsh_exit'
-# fi
-# use $2
-# [ -n "$ZSH_VERSION" ] && [ "$USER" = richih ] && buildPS1
-# verbose "use end"
-# exit 0
-
-elif [ "$1" = 'clone' ]; then
+ export VCSH_EXTERNAL_COMMAND="$*"
+ if [ "$VCSH_COMMAND" = 'run' ]; then
+ [ -z "$VCSH_EXTERNAL_COMMAND" ] && echo "$SELF $1 $2: error: please specify a command" && return 1
+ fi
+elif [ "$1" = 'help' ] ||
+ [ "$1" = 'list' ]; then
+ export VCSH_COMMAND="$1"
+else
+ [ -z $1 ] && help && return 0
+ export VCSH_COMMAND='run'
+ export VCSH_REPO_NAME="$1"
+ export GIT_DIR="$VCSH_BASE/$VCSH_REPO_NAME.git"
+ [ -d $GIT_DIR ] || (help && return 1) || return 0
+ shift 1
+ export VCSH_EXTERNAL_COMMAND="git $*"
+fi
+
+
+for check_directory in "$VCSH_BASE" "$HOME/.gitignore.d"
+do
+ if [ ! -d "$check_directory" ]; then
+ if [ -e "$check_directory" ]; then
+ echo "$SELF: error: $check_directory exists but is not a directory" >&2
+ return 2
+ else
+ echo "$SELF: info: attempting to create $check_directory"
+ mkdir -p "$check_directory" || (echo "$SELF: error: could not create $check_directory" >&2; return 2) || return $?
+ fi
+ fi
+done
+
+
+if [ "$VCSH_COMMAND" = 'clone' ]; then