7

To simplify my concern, I narrowed it to the following:

I have a GIT alias defined as such:

cii = "!f() { git commit "$@"; }; f" 

When I run

$ git cii -m "test1" 

It works fine, but it fails with

$ git cii -m "test1 and test2" error: pathspec 'and' did not match any file(s) known to git. error: pathspec 'test2' did not match any file(s) known to git. 

Any idea ?

Note that my real alias is much more complex that the above, so responding with cii = "commit" is not an option. The point here is passing the input parameters to the function.

1
  • Why "and"? Why not just git cii -m test test1? Commented Jun 17, 2013 at 21:48

1 Answer 1

8

You need to quote the embedded doublequotes.

cii = "!f() { git commit \"$@\"; }; f" 

git will then perform standard shell expansion of "$@" which translates to a single word for each parameter - like "$1" "$2" "$3" ...

Sign up to request clarification or add additional context in comments.

1 Comment

yes, looks like it. yet my real alias is still failing.. think I didn't narrow the right issue.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.