bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Could we have a flag to tell us which directories were actually remo


From: Bob Proulx
Subject: Re: Could we have a flag to tell us which directories were actually removed?
Date: Wed, 15 Aug 2007 22:48:37 -0600
User-agent: Mutt/1.5.9i

Reuben Thomas wrote:
> I wanted this for keyboard use, for multiple directories:
>   rmdir [--magic-flag] *

Let me keep working the problem...  How about this?

  perl -le 'for my $i (@ARGV) { print $i if rmdir($i); };' *

That would be quite easy to turn into a script to reuse more often
such as on the command line.

  #!/bin/sh
  exec perl -le 'for my $i (@ARGV) { print $i if rmdir($i); };' "$@"

> in fact. Maybe it's just not common enough a case?

It does seem pretty unusual to me to want to do something like that
and I have not wanted to do it before.  In fact thinking about it a
little bit more and this seems to be actively bad to me.  I think the
reverse information is really what I would want to see.

I am pretty pedantic about checking for errors.  The reason I don't
like the above is that I can't tell the difference between a failure
to remove the directory and a failure to remove the directory.  I mean
sure it is possible to print out which directories were removed and
that is fine for the directories that were actually removed.  But what
if there is a problem?  Already there is an expectation that some
directories won't get removed because of the error that they are not
empty.  But what about other errors such as permissions and read-only
filesystems and I/O errors and other things?  They are errors that I
would want to know about.  I think it is better to perform actions
purposefully and to verify that the action did succeed.

But for some keyboard activities I am okay with being lazy.  I have
often simply done 'rmdir *' and then looked to see what resulted.  I
know that only empty directories will get removed and it will spew
errors for the others and I ignore that.  But since I will look
immediately at the result and deal with the new state that seems
okay.  If a directory that I think should have been removed was not I
can simply inspect it and 'rm -rf' it if needed.

So for me I would almost always want the reverse of this information.
I almost never want to know the names of the directories that I
removed.  I would almost always want to know the names of the
directories that did *not* get removed.  I assume that I am not alone
in this since this is also the behavior we currently have from the
commands for all of these years.  The reverse information just does
not feel right to me.

Bob




reply via email to

[Prev in Thread] Current Thread [Next in Thread]