X-Git-Url: https://git.madduck.net/code/vcsh.git/blobdiff_plain/d4326c2c1c2d5e9626f8d9e2ba0e5e3848772238..68c93dceb42ee275b339d421bbf77eaf62363d31:/vcsh?ds=inline diff --git a/vcsh b/vcsh index 50c1c31..cfcb42a 100755 --- a/vcsh +++ b/vcsh @@ -48,7 +48,7 @@ info() { echo "$SELF: info: $1" } -clone () { +clone() { init git remote add origin "$GIT_REMOTE" git config branch.master.remote origin @@ -65,10 +65,10 @@ clone () { git merge origin/master } -delete () { +delete() { old_dir="$PWD" cd "$HOME" - use || exit $? + use info "This operation WILL DETROY DATA!" files=$(git ls-files) echo "These files will be deleted: @@ -86,8 +86,8 @@ To continue, type \"Yes, do as I say\"" cd "$old_dir" } -enter () { - use || exit $? +enter() { + use $SHELL } @@ -96,24 +96,23 @@ init() { export GIT_WORK_TREE="$HOME" mkdir -p "$GIT_WORK_TREE" cd "$GIT_WORK_TREE" || fatal "could not enter '$GIT_WORK_TREE'" 11 - cd "$GIT_WORK_TREE" git init setup } -list () { +list() { for i in "$VCSH_BASE"/*.git; do echo $(basename "$i" .git) done } -run () { - use || exit $? +run() { + use $VCSH_EXTERNAL_COMMAND } -seed_gitignore () { - use || exit $? +seed_gitignore() { + use # Switching directory as this has to be executed from $HOME to be of any use. # Going back into old directory at the end in case `vcsh use` is reactivated. old_dir="$PWD" @@ -155,8 +154,7 @@ setup() { use() { if [ ! -d "$GIT_DIR" ]; then - error "no repository found for '$VCSH_REPO_NAME'" - return 12 + fatal "no repository found for '$VCSH_REPO_NAME'" 12 fi export GIT_WORK_TREE="$(git config --get core.worktree)" export VCSH_DIRECTORY="$VCSH_REPO_NAME" @@ -180,8 +178,8 @@ elif [ "$1" = 'delete' ] || export VCSH_COMMAND="$1" export VCSH_REPO_NAME="$2" export GIT_DIR="$VCSH_BASE/$VCSH_REPO_NAME.git" - [ "$1" = 'run' ] && shift 2 && export VCSH_EXTERNAL_COMMAND="$@" - [ "$1" = 'seed-gitignore' ] && export VCSH_COMMAND=seed_gitignore + [ "$VCSH_COMMAND" = 'run' ] && shift 2 && export VCSH_EXTERNAL_COMMAND="$@" + [ "$VCSH_COMMAND" = 'seed-gitignore' ] && export VCSH_COMMAND='seed_gitignore' elif [ "$1" = 'list' ]; then export VCSH_COMMAND="$1" elif [ -n "$1" ]; then