]> git.madduck.net Git - code/vcsh.git/blobdiff - vcsh

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Use explicit variable names and improve quoting
[code/vcsh.git] / vcsh
diff --git a/vcsh b/vcsh
index 50c1c31c7e63487a28ecb54b1cbaa8085b046527..029c42c4c5f0348647c7cecb1673cb495b637a95 100755 (executable)
--- 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
 }
 
@@ -101,19 +101,19 @@ 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 +155,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 +179,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