Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #107519

Re: Remove directory tree without following symlinks

From Random832 <random832@fastmail.com>
Newsgroups comp.lang.python
Subject Re: Remove directory tree without following symlinks
Date 2016-04-23 17:04 -0400
Message-ID <mailman.12.1461445479.32212.python-list@python.org> (permalink)
References <571a3ba2$0$1597$c3e8da3$5496439d@news.astraweb.com> <877ffon3nd.fsf@nightsong.com> <571b4d75$0$1598$c3e8da3$5496439d@news.astraweb.com> <1461445469.3526344.587631697.21F2B303@webmail.messagingengine.com>

Show all headers | View raw


On Sat, Apr 23, 2016, at 06:24, Steven D'Aprano wrote:
> "rm -r" gives me a NameError when I run it in my Python script :-)
> 
> But seriously, where is that documented? I've read the man page for
> rm, and it doesn't say anything about treatment of symlinks, nor is
> there an option to follow/not follow symlinks. So I never trust rm -r
> unless I know what I'm deleting.

The Unix Standard says "For each entry contained in file, other than dot
or dot-dot, the four steps listed here (1 to 4) shall be taken with the
entry as if it were a file operand. The rm utility shall not traverse
directories by following symbolic links into other parts of the
hierarchy, but shall remove the links themselves." and "The rm utility
removes symbolic links themselves, not the files they refer to, as a
consequence of the dependence on the unlink() functionality, per the
DESCRIPTION. When removing hierarchies with -r or -R, the prohibition on
following symbolic links has to be made explicit."

OSX (and I assume other BSDs) says "The rm utility removes symbolic
links, not the files referenced by the links."

I don't know why GNU rm's documentation doesn't say anything about its
treatment of symlinks - maybe it never occurred to anyone at GNU that
someone might think it would do anything else.

(I'd be less inclined to trust windows' treatment of symlinks,
junctions, and other reparse points without doing some experiments)

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Remove directory tree without following symlinks Steven D'Aprano <steve@pearwood.info> - 2016-04-23 00:56 +1000
  Re: Remove directory tree without following symlinks Random832 <random832@fastmail.com> - 2016-04-22 11:09 -0400
    Re: Remove directory tree without following symlinks Steven D'Aprano <steve@pearwood.info> - 2016-04-23 03:14 +1000
      RE: Remove directory tree without following symlinks Albert-Jan Roskam <sjeik_appie@hotmail.com> - 2016-04-22 17:39 +0000
      Re: Remove directory tree without following symlinks eryk sun <eryksun@gmail.com> - 2016-04-22 13:28 -0500
      RE: Remove directory tree without following symlinks Albert-Jan Roskam <sjeik_appie@hotmail.com> - 2016-04-23 09:34 +0000
      Re: Remove directory tree without following symlinks eryk sun <eryksun@gmail.com> - 2016-04-23 15:22 -0500
      Re: Remove directory tree without following symlinks eryk sun <eryksun@gmail.com> - 2016-04-24 14:42 -0500
  Re: Remove directory tree without following symlinks Paul Rubin <no.email@nospam.invalid> - 2016-04-23 01:13 -0700
    Re: Remove directory tree without following symlinks Steven D'Aprano <steve@pearwood.info> - 2016-04-23 20:24 +1000
      Re: Remove directory tree without following symlinks Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2016-04-23 23:37 +1200
      Re: Remove directory tree without following symlinks Random832 <random832@fastmail.com> - 2016-04-23 17:04 -0400
  Re: Remove directory tree without following symlinks Nobody <nobody@nowhere.invalid> - 2016-04-23 17:29 +0100
    Re: Remove directory tree without following symlinks Random832 <random832@fastmail.com> - 2016-04-23 17:07 -0400

csiph-web