Derek Balling <[email protected]> wrote:
> 
> On Oct 24, 2012, at 11:30 AM, Jan Schaumann <[email protected]> wrote:
> >> A new user I knew was trying to clean out some old accounts on a system
> >> he was given.  As root, he changed directories to one of the old user
> >> directories, and then did 'rm -r *' but noticed it left a directory
> >> called .X11 behind.  To get rid of it, and to be sure it wouldn't fail,
> >> he did 'rm -rf .*'.  Sad to say he didn't realize that '.*' could and
> >> would expand into '..', and it would continue to do so recursively.
> > 
> > Did early versions of (any) Unix really behave this way?  I don't see
> > how:
> > 
> > '.*' is expanded by the shell at command invocation time.  That does in
> > fact get expanded to include '.' and '..', but it does not recursively
> > expand to '../.' and '../..' etc.
> 
> "-r" ... so it recursively runs the command against anything marked as a 
> directory,... which ".." satisfies. So it would recursively go "into" the .. 
> directory tree, and then delete whatever files/directories were in that 
> directory. Lather, rinse, repeat.

That would require rm(1) to fork-exec a new shell for each subdir to
allow the shell to newly expand the given args.

Instead, the earliest sources I can find quickly all behave as one would
expect and use fts(3) to traverse the hierarchy.

I seem to recall having seen a link somewhere pointing to historical
unix sources, but I can't quickly find it right now.  Anybody got a
pointer?

-Jan

Attachment: pgpKGTZO5Pc9V.pgp
Description: PGP signature

_______________________________________________
Discuss mailing list
[email protected]
https://lists.lopsa.org/cgi-bin/mailman/listinfo/discuss
This list provided by the League of Professional System Administrators
 http://lopsa.org/

Reply via email to