1

Currently I have this and it works as expected if I use it like addcommit 'test commit' but if I use it as addcommit test commit it only sees the first word test. Ideally I'd like to have the functionality of addcommit test commit and it executing git add . && git commit -m 'test commit'

addcommit()
{   
    git add . && git commit -m "$1"
}

PS. I don't understand how the "$1" works in this case, maybe that would be a good starting point to understanding how this should work.

1

Replace "$1" with "$*".

And in order to be completely safe against IFS traps:

addcommit()
{
   local IFS=' '
   git add . && git commit -m "$*"
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.