Skip to content

Commit

Permalink
Fix opt processing, avoid eval and useless cat
Browse files Browse the repository at this point in the history
  • Loading branch information
alerque committed Apr 3, 2021
1 parent ed5ffed commit 6e488c8
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions vcsh
Original file line number Diff line number Diff line change
Expand Up @@ -235,20 +235,21 @@ foreach() {
# We default to prefixing `git` to all commands passed to foreach, but
# allow running in general context with -g
command_prefix=git
command_suffix='cat'
while getopts "gp" flag; do
if [ x"$1" = x'-g' ]; then
unset command_prefix
fi
if [ x"$1" = x'-p' ]; then
command_suffix='sed "s/^/$VCSH_REPO_NAME: /"'
fi
shift 1
while getopts gp flag; do
case "$flag" in
g) unset command_prefix;;
p) VCSH_PRINT_REPO_PREFIX=true;;
esac
done
shift $((OPTIND-1))
for VCSH_REPO_NAME in $(list); do
GIT_DIR=$VCSH_REPO_D/$VCSH_REPO_NAME.git; export GIT_DIR
use
$command_prefix "$@" | eval $command_suffix
if [ -n "${VCSH_PRINT_REPO_PREFIX+x}" ]; then
$command_prefix "$@" | sed "s/^/$VCSH_REPO_NAME: /"
else
$command_prefix "$@"
fi
done
hook post-foreach
}
Expand Down

0 comments on commit 6e488c8

Please sign in to comment.