开发者

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.)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜