0

I've got a unix-shell script that's supposed to work on nix machines. This doesn't run on OS X however, due to "cp" command not defined. Changing it to "copy" didn't help.

git log -1 --pretty=format:"%h" | xargs -I %id% git diff-tree --no-commit-id --name-only -r %id% | xargs -I % cp --parents % upd/ 

The script should make a copy of files changed in last git commit.

3
  • I'm wondering if it has more to do with the percentage sign than with cp. Because cp should be available in any case, it's such a basic command. Commented May 17, 2015 at 18:21
  • 2
    or "cp" on OS X doesn't know the --parents option Commented May 17, 2015 at 18:23
  • If you have Command Line Tools for Xcode installed you can download GNU core utilities and install the GNU version of cp which works with --parents. I just tested it and it works nice. Commented May 17, 2015 at 19:43

1 Answer 1

3

Have a look at this SO thread: https://stackoverflow.com/questions/11246070/cp-parents-option-on-mac

cp is available on OS X, but it does not support the --parents option, as I guessed. Instead of using cp --parents, replace it with ditto as mentioned in the SO answer.

1
  • Thanks, I will look at it and possibly reply with a solution. Commented May 17, 2015 at 18:27

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.