-
Notifications
You must be signed in to change notification settings - Fork 125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable vcsh ls-file to take an option '-p' #285
Changes from 1 commit
ed5ffed
87c12fe
8edd4c7
680cd47
5dbb251
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -110,7 +110,8 @@ help() { | |
delete <repo> Delete an existing repository | ||
enter <repo> Enter repository; spawn new instance of \$SHELL | ||
with \$GIT_DIR set. | ||
foreach [<-g>] | ||
foreach \\ | ||
[<-g>] [<-p>] \\ | ||
<git command> Execute a command for every repository | ||
help Display this help text | ||
init <repo> Initialize a new repository | ||
|
@@ -234,17 +235,20 @@ foreach() { | |
# We default to prefixing `git` to all commands passed to foreach, but | ||
# allow running in general context with -g | ||
command_prefix=git | ||
while getopts "g" flag; do | ||
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 | ||
done | ||
for VCSH_REPO_NAME in $(list); do | ||
echo "$VCSH_REPO_NAME:" | ||
GIT_DIR=$VCSH_REPO_D/$VCSH_REPO_NAME.git; export GIT_DIR | ||
use | ||
$command_prefix "$@" | ||
$command_prefix "$@" | eval $command_suffix | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This doesn't feel right to me, I think we can probably do better with an |
||
done | ||
hook post-foreach | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method of option parsing just doesn't work right at all, you can't use
-g -p
or-p -g
because the manual shift is eating the argument and throwinggetopts()
off. Speaking of which, this isn't howgetopts()
is supposed to work at all, and the flag variable it sets is being ignored. I don't know how the top level option parsing got away with this for so long, but I don't think it's correct either....There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See also #286 for a PR that fixes the
getopts()
usage for the main script.