bug-fileutils
[Top][All Lists]
Advanced

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

Re: a serious bug in "mv"


From: Alfred M. Szmidt
Subject: Re: a serious bug in "mv"
Date: Fri, 7 Nov 2003 15:01:00 +0100 (MET)

   > Actually, this has nothing to do with mv, which was obediently doing what
   > it was told to do, and everything to do with shell wildcard expansion
   > (which was also behaving).  It is just an unfortunate accident.

   Well, sounds like a "undocumented feature a la Microsoft". :o\

Shell expanision is quite well documented, if you are using bash then
(bashref)Pattern Matching, will tell you all about it.

   So, I consider this to be a bug, unless there is any intentionally
   planned shell or OS action requiring this kind of formatting of
   strings in the Linux system. Can you give any example where this
   feature is used intentionally?

No it is not a bug.  Shell expanision of the above form is heavily
used, take the following example:

$ for x in *; do; do_something_with $x; done

or if you accidently scrwed up ls for whatever reason:

$ echo *

As for using it with mv, or any other destructive utlitity, its
impossible to detect this sanely. Are you going to start detecting
typos like (holding the shift key a bit to long, the command that was
supposed to be written is the comment):

$ cat * >*                       # cat * .*

Or what about:

$ echo *>*                       # echo * .*

Where would this "safe expansion detection" stop?  The only good
solution is to know the tools you are working with.


Also, would you like to help us stop spreading the confusion that
Linux is an operating system?  Linux is `only' a kernel, the system
you are really using is a variant of GNU, with Linux as its kernel:
GNU/Linux.  You can read more about this issue at
http://www.gnu.org/gnu/linux-and-gnu.html.

   I happened to have a recent backup, so the harm was not that
   big. But still, the "mv" command behaved unexpectedly.

No, mv behaved as it should be have, `you' type in (after shell
expansion)

$ mv dir/foo dir/bar

That you meant it or not is irrelevant, what if you did really want to
move dir/foo to dir/bar by using shell expansion?  If you want to be
warned of such things, the you should use the --interactive switch.


Cheers.




reply via email to

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