1

I am trying to make a bash script which will:

  1. Add all changes to git
  2. Commit with a message I pass to the bash script
  3. Push it to the repo

I am trying to do this with:

m=\"$*\" git add -A echo git commit -m $m git push 

However, I am getting errors saying error: pathspec 'Q2,' did not match any file(s) known to git. for everything word I pass to the script.

How can I see what bash it actually doing? When I put echo in front of the offending line (which I presume is the commit) I get a correctly form command. If I put it in to the terminal, I runs find.

1 Answer 1

4

To see what bash is doing, add -xv options to the shebang line:

#!/bin/bash -xv 

The problem is probably the quoting. m=\"$*\" does not do what you want. $m is still split into several words if it contains whitespace, just the first word starts with a doublequote and the last word ends in a doublequote.

Rather, change the offending line to

git commit -m "$m" 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.