The Unix Heritage Society mailing list
 help / color / mirror / Atom feed
From: jnc@mercury.lcs.mit.edu (Noel Chiappa)
Subject: [TUHS] There is turmoil in Linux-land - When did rm first avoid going upwards?
Date: Mon, 24 Apr 2017 21:34:03 -0400 (EDT)	[thread overview]
Message-ID: <20170425013403.694CE18C0C3@mercury.lcs.mit.edu> (raw)

    > From: Kurt H Maier

    > /etc/glob, which appears to report no-match if the first character is .

So I couldn't be bothered to work out how 'glob' worked exactly, so I just did
an experiment: I created a hacked version of 'rm' that had the directory
handling call to glob call 'echo' instead of 'rm'; it also printed 'tried'
instead of the actual unlink call, and printed 'cd' when it changed
directories.

I then set up two subsidiary directors, foo and .bar, with one containing
'.foo0 foo1' and the other '.bar0 bar1'.

Saying 'xrm -r -f .*' produced this:

  cd: .
  -r -f foo xrm xrm.c
  cd: ..
  -r -f foo xrm xrm.c
  cd: .bar
  -r -f bar1 

(This system has /tmp on a mounted file system, which is why the 'cd ..' was a
NOP. And a very good thing, too; at one point the phone rang, and it
distracted me, and I automatically typed 'rm', not 'xrm'... see below for what
happened. No biggie, there were only my test files there.  The output lines
are "-r -f foo xrm xrm.c" because that's what 'glob' passed to 'echo'.)

Saying 'xrm -r -f *' produced this:

  cd: foo
  -r -f foo1
  xrm: tried
  xrm.c: tried     

So apparently 'glob', when presented with '*' , ignores entries starting with
'.', but '.*' does not.


When I stupidly typed 'rm -r -f .*', it did more or les what I originally
thought it would: deleted all the files in all the directories (but only on
the /tmp device, because .. linked to the itself in /tmp, so it didn't escape
from that volume); leaving all the directories, but empty, except for the
files .foo0 and .bar0. So files and inferior directories with names starting
with '.' would have escaped, but nothing else.

	Noel


             reply	other threads:[~2017-04-25  1:34 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-25  1:34 Noel Chiappa [this message]
  -- strict thread matches above, loose matches on Subject: below --
2017-04-25  0:59 Noel Chiappa
2017-04-24 22:06 Noel Chiappa
2017-04-24 22:18 ` Josh Good
2017-04-24 23:23   ` Kurt H Maier
2017-04-25  0:06     ` Ron Natalie
2017-04-25  0:18       ` Kurt H Maier
2017-04-25  0:22         ` ron minnich
2017-04-25  0:24           ` Kurt H Maier
2017-04-25  0:26             ` ron minnich
2017-04-24 21:42 Josh Good
2017-04-24 21:48 ` Alec Muffett
2017-04-24 21:59   ` Arthur Krewat
2017-04-24 22:10 ` Kurt H Maier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170425013403.694CE18C0C3@mercury.lcs.mit.edu \
    --to=jnc@mercury.lcs.mit.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).