English Idiom in Unix: Directory Recursively

Steven D'Aprano steve+comp.lang.python at pearwood.info
Thu May 26 06:06:44 EDT 2011


On Thu, 26 May 2011 10:48:07 +0200, Thorsten Kampe wrote:

> But not to digress, the /real/ problem with commands or idioms like "rm
> -r" is /not/ their choice of option names but that they explain these
> options in the exact same terms. No one would have a problem with "-r,
> --recursive -- remove directories including all sub-directories" instead
> of "-r, --recursive -- remove directories and their contents
> recursively".

I think you are understanding the description "remove directories and 
their contents recursively" as a description of the *mechanism* by which 
rm removes the directory, i.e. some recursive tree-walking function that 
visits each node and deletes it.

I don't believe that's how the description is meant to be understood. I 
understand it as describing the effect, not the implementation. If the 
tree-walker was re-written to be iterative, the description would not 
need to be changed. It is meant to be understood as:

rm -r foo

* deletes foo
* deletes things inside foo
* if any of those things inside foo are directories, delete them too, in 
exactly the same way (i.e. "recursively").

Notice that, strictly speaking, the description is impossible. You can't 
delete the top level directory first. But that's how the human reader 
will understand it: 

* delete the directory you point it at, plus the things inside it in the 
same way

rather than how the implementation (probably) does it:

* drill down all the way to the bottom, start deleting like mad, and work 
your way back up the stack, deleting as you go.


You're interpreting the reference to "recursive" as a nod to the 
implementation. I'm not, and therefore your arguments don't convince me.


-- 
Steven



More information about the Python-list mailing list