Hey I'm writing a wrapper script for git that applies one git command to all its submodules e.g.: supergit commit -m "change message"
commits to all submodules.
The script essentially does:
function git_foreach () {
git submodule foreach "git \"$@\" || : "
}
git_foreach "$@"
The problem is when the supergit call contains an argument with spaces (like in the commit message above) the space separated calls are interpreted as multiple arguments.
I read in this answer that the way to do it is to use "$@"
but that doesn't work within a string.
Is there a way to expand $@
to keep the quotes so that my function works as expected?
EDIT:
What I want is to pass the arguments to git submodule foreach
, with supergit commit -m "commit message"
I want to run:
git submodule foreach "git commit -m \"commit message\""