From: Richard Hartmann Date: Fri, 3 Apr 2015 17:36:10 +0000 (+0200) Subject: vcsh: Implement skeleton of `vcsh foreach` X-Git-Url: https://git.madduck.net/code/vcsh.git/commitdiff_plain/00e3e4ee67e7724e8b90f32abc67c05ac37720b7 vcsh: Implement skeleton of `vcsh foreach` No help, completion, or other related updates --- diff --git a/vcsh b/vcsh index 0f2c5af..a5c3f48 100755 --- a/vcsh +++ b/vcsh @@ -214,6 +214,16 @@ enter() { hook post-enter } +foreach() { + hook pre-foreach + for VCSH_REPO_NAME in $(list); do + GIT_DIR=$VCSH_REPO_D/$VCSH_REPO_NAME.git; export GIT_DIR + use + "$@" + done + hook post-foreach +} + git_dir_exists() { [ -d "$GIT_DIR" ] || fatal "no repository found for '$VCSH_REPO_NAME'" 12 } @@ -546,6 +556,9 @@ elif [ x"$VCSH_COMMAND" = x'delete' ] || [ x"$VCSH_COMMAND" = x'rename' ] && { VCSH_REPO_NAME_NEW=$3; export VCSH_REPO_NAME_NEW; GIT_DIR_NEW=$VCSH_REPO_D/$VCSH_REPO_NAME_NEW.git; export GIT_DIR_NEW; } [ x"$VCSH_COMMAND" = x'run' ] && shift 2 +elif [ x"$VCSH_COMMAND" = x'foreach' ]; then + [ -z "$2" ] && fatal "$VCSH_COMMAND: please specify a command" 1 + shift 1 elif [ x"$VCSH_COMMAND" = x'commit' ] || [ x"$VCSH_COMMAND" = x'list' ] || [ x"$VCSH_COMMAND" = x'list-tracked' ] ||