9

I'm following an installation script on GitHub and one of the steps is:

cp sources/openssl/1.0.1p/Android.mk -o sources/openssl/$OPENSSL_VERSION/Android.mk

But my terminal threw an error cp: invalid option -- 'o'

I checked man cp on my Ubuntu, and there's no option -o. Is this a MAC OS thing? What does cp -o stand for?

dr_
  • 29,602
Adhy Satya
  • 105
  • 1
  • 4
  • I'm not sure where the -o came from but I am presuming that it isn't needed and the copy is simply copying from one source destination to a source directory – Raman Sailopal Oct 06 '17 at 13:44

2 Answers2

9

That's a typo. There is no implementation of cp that has a -o option on any Unix that I know of. My guess is that this option may safely be removed.

It may be that they meant cp -p (preserve mode, timestamp and ownership when used with GNU cp and others), or cp -i for interactive prompting in case the file already exists.

They are obviously using GNU cp though, since they intermingle operands with options. Ordinary tools usually stop parsing the command line at the first non-option, but GNU tools will try to be smart.

Kusalananda
  • 333,661
  • Anyway, cp file -o dir is meant to copy the file and -o files to dir. Only GNU (or GNU-like like busybox) cp would take that -o as an option (and only when $POSIXLY_CORRECT is not in the environment) – Stéphane Chazelas Oct 06 '17 at 13:55
  • 2
    Possibly it was confusion with the common curl-o. But this is all guesswork. Only Lei Pi can really explain. – JdeBP Oct 06 '17 at 13:56
  • With GNU cp, cp --o would be an abbreviation for cp --one-file-system. I agree with JdeBP that it is just a typo especially considering that the next section does something similar with curl -o. It's not any indication that they're using GNU cp or any other implementation. – Stéphane Chazelas Oct 06 '17 at 14:03
  • @StéphaneChazelas On ubuntu --one-file-system option is abbreviated to -x – user000001 Oct 06 '17 at 15:13
  • 1
    @user000001, yes, but --o (or --on, or --one...) would also work (note the double dash) – Stéphane Chazelas Oct 06 '17 at 15:20
  • @StéphaneChazelas: Ah, I missed the second dash. It's really cool that you can abbreviate long options like that, I hadn't realized it even after many years of using linux. Thanks for letting me know :) – user000001 Oct 06 '17 at 15:25
  • 3
    @user000001 If you ever write a script (or documentation), don't abbreviate the options though. It makes it unnecessarily hard to understand. – Kusalananda Oct 06 '17 at 15:27
5

You can safely remove the -o option. Btw, is $OPENSSL_VERSION set?