Git alias with arguments having spaces

I can't find any example of a git alias that allows arguments with spaces, this is what I created:

cax = "!f() { msg=${1-Default message}; git add --all && git commit -am "$msg"; }; f"

      

This works great:

git cax "one-word"

      

But breaks down with:

git cax "one word"

      

Thank!

+3


source to share


1 answer


Did you notice odd syntax highlighting in your question?

cax = "! f () {msg = $ {1-Default message}; git add --all && git commit -am" $ msg ";}; f"
^^^^^^^ ^^^^ black
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^ ^^^^^^^^^ red


It had to be a big hint. The problem is that it is $msg

not specified in your function definition. The symbols are "

handled specifically by Git when it reads your config file, but you want to pass those two symbols to the shell. Use instead \"$msg\"

.

+3


source







All Articles