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


Groups > comp.lang.python > #107519

Re: Remove directory tree without following symlinks

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From Random832 <random832@fastmail.com>
Newsgroups comp.lang.python
Subject Re: Remove directory tree without following symlinks
Date Sat, 23 Apr 2016 17:04:29 -0400
Lines 27
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>
Mime-Version 1.0
Content-Type text/plain
Content-Transfer-Encoding 7bit
X-Trace news.uni-berlin.de uvFGqZqO6aN9ezi0NeI26gIEaqzpaT6GzheECZOMfASg==
Return-Path <random832@fastmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.002
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'removes': 0.05; "(i'd": 0.09; 'received:internal': 0.09; 'themselves,': 0.09; 'python': 0.10; 'assume': 0.11; ':-)': 0.12; 'file,': 0.15; '23,': 0.16; 'hierarchy,': 0.16; 'inclined': 0.16; 'message- id:@webmail.messagingengine.com': 0.16; 'nameerror': 0.16; 'osx': 0.16; 'received:10.202': 0.16; 'received:10.202.2': 0.16; 'received:10.202.2.212': 0.16; 'received:66.111': 0.16; 'received:66.111.4': 0.16; 'received:io': 0.16; 'received:messagingengine.com': 0.16; 'received:psf.io': 0.16; 'subject:Remove': 0.16; 'traverse': 0.16; 'wrote:': 0.16; 'symbolic': 0.22; 'sat,': 0.23; 'unix': 0.24; 'header:In-Reply- To:1': 0.24; 'script': 0.25; "i've": 0.25; "doesn't": 0.26; 'points': 0.27; 'gnu': 0.27; 'consequence': 0.29; 'occurred': 0.29; 'referenced': 0.29; "i'm": 0.30; 'entry': 0.31; 'option': 0.31; 'anyone': 0.32; '"the': 0.32; 'says': 0.32; 'maybe': 0.33; 'run': 0.33; "d'aprano": 0.33; 'steven': 0.33; 'utility': 0.33; 'file': 0.34; 'gives': 0.35; 'but': 0.36; 'there': 0.36; '(and': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'received:10': 0.37; 'say': 0.37; 'doing': 0.38; 'received:66': 0.38; 'anything': 0.38; 'someone': 0.38; 'files': 0.38; 'why': 0.39; 'to:addr:python.org': 0.40; 'where': 0.40; 'some': 0.40; 'header:Message-Id:1': 0.61; 'per': 0.62; 'to,': 0.63; 'else.': 0.66; 'here': 0.66; 'links,': 0.76; 'subject:tree': 0.84; 'seriously,': 0.91; 'treatment': 0.95
DKIM-Signature v=1; a=rsa-sha1; c=relaxed/relaxed; d=fastmail.com; h= content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-sasl-enc :x-sasl-enc; s=mesmtp; bh=mfo/2ITz0fKHcqpUPVcSciIDKaw=; b=fuLmKv voX35gLymwVfzuNhEQzxLh0TST/DsZo/UqGeZktLbtvELJcU1cQnnB818JW5eAyV FQBFTpzbqiQKm2khXKIWwJIG/Egr3RiyPgHLjlwShPu0kifldE6FuMK4MZjxIkOC rSLy9WmX0nlYVSbiayCW+ZfzXrTAwDmvNbrwY=
DKIM-Signature v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-sasl-enc:x-sasl-enc; s=smtpout; bh=mfo/2ITz0fKHcqp UPVcSciIDKaw=; b=hNO+JW/eLuuRBeZSs+vjkLkWA5d/LzT23mL6kSXodiq9zUV AgFF72DzgSMh3jVie6HtEwvZ7rCFL/DKfQOAqlMwFhHGJxsxl/6saHQwj4OBSZ0p HCCQA+0PRcxd0SYwxEXMGRmxm0asM7VUGfzPaAjz1jeu/sTxTk3w5nzhDMn8=
X-Sasl-Enc TJtskSZH8letzVKleX/0v9RkdPYp3UNOFzBQQYbLUlZ1 1461445469
X-Mailer MessagingEngine.com Webmail Interface - ajax-76f1c811
In-Reply-To <571b4d75$0$1598$c3e8da3$5496439d@news.astraweb.com>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.22
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID <1461445469.3526344.587631697.21F2B303@webmail.messagingengine.com>
X-Mailman-Original-References <571a3ba2$0$1597$c3e8da3$5496439d@news.astraweb.com> <877ffon3nd.fsf@nightsong.com> <571b4d75$0$1598$c3e8da3$5496439d@news.astraweb.com>
Xref csiph.com comp.lang.python:107519

Show key headers only | 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