Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Some commands use a lower case r for their recursive flag while others use a capital letter R.

cp -r foo/ bar/

chmod -R 777 foobar/

Is there a reason for this?

share|improve this question
add comment

2 Answers 2

up vote 5 down vote accepted

cp actually accepts both.

From cp --help:

  -R, -r, --recursive          copy directories recursively

For consistency, most shell commands use -R as a recursive flag, probably because they imitate the behavior of ls.

From ls --help:

  -r, --reverse              reverse order while sorting
  -R, --recursive            list subdirectories recursively
share|improve this answer
1  
Also, chmod -r is already used to mean something other than recursive! –  Darth Android Jun 19 '12 at 18:24
add comment

I'm not sure that there's any specific reason to the inconsistancy other than that programmers can choose to use whatever flags they want.

I don't think there's any form of standard for that so it's hard to expect everyone to follow suit.

share|improve this answer
5  
The reason would likely be historical. In the larger Unix world which dates all the way back to the 70s, the recursive switches weren't always there, and some commands already had made use of -r as a switch. Because commands are often used within scripts, there's tremendous inertia associated with backwards compatibility, so these things basically never change - you can add options to a program, but woe be the developer who tries to change long-established functionality. –  Stephanie Jun 19 '12 at 18:51
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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