How do I pass $@ as a single argument to another command in a bash function?
I have this as a bash function:
function git开发者_运维问答s() {
git grep -i -n --color $@ -- $(git rev-parse --show-toplevel);
}
If I run this:
gits def add_crumb
I want:
git grep -i -n --color "def add_crumb" -- $(git rev-parse --show-toplevel)
The purpose of $@
is specifically to split it into individual arguments. Use "$*"
if you don't want that. (Yes, with the double quotes; you should have them in "$@"
as well, actually.)
精彩评论