GNU bug report logs - #6104
[Expert] Bug in mv?

Previous Next

Package: coreutils;

Reported by: Gene Heskett <gene.heskett <at> gmail.com>

Date: Wed, 5 May 2010 03:56:01 UTC

Severity: normal

Merged with 6118

Done: Bob Proulx <bob <at> proulx.com>

Bug is archived. No further changes may be made.

Full log


Message #8 received at 6104 <at> debbugs.gnu.org (full text, mbox):

From: Eric Blake <eblake <at> redhat.com>
To: Gene Heskett <gene.heskett <at> gmail.com>
Cc: 6104 <at> debbugs.gnu.org, expert <at> mandrivalinux.org
Subject: Re: bug#6104: [Expert] Bug in mv?
Date: Wed, 05 May 2010 15:02:56 -0600
[Message part 1 (text/plain, inline)]
On 05/04/2010 09:09 PM, Gene Heskett wrote:
> On Tuesday 04 May 2010, João Victor Martins wrote:
>> On Tue, May 04, 2010 at 10:36:19PM -0400, Gene Heskett wrote:
>>> I tried to "mv amanda* /home/amanda/*" as root and which
>>> which I recall I have done successfully several times before.
>>
>> The shell expand * _before_ passing the args to mv.  So mv saw all
>> files starting with 'amanda' and all files (besides . hidden ones) in
>> /home/amanda/ as arg.  It then picked the last one listed (probably
>> /home/amanda/tmp/) as destination.

This analysis is correct.

>>
> I had two files whose names started with amanda in that directory.  I would 
> have assumed it would expand the src pattern of "amanda*" to match only those 
> two files.  And the rest of the files in /home/me, weren't bothered.  No 
> damages to the src directory at all other than removing the files.
> 
> If it expanded that * to include the whole thing, it should have moved the 
> whole thing.  It didn't.  In past experience, the target path spec's /* has 
> always served as just a place holder for the filenames actually selected by 
> the amanda* in the src spec.

Huh?  Globbing has never worked like that.  Globbing is done by the
shell, not by mv, so by the time mv is started, the * has already been
converted into one or more filenames.

Maybe you are thinking of the rename(1) or mmv(1) utility provided by
some distros (but not part of coreutils), where, with proper quoting (so
that the * goes through as argv of the rename command, which then does
the pattern manipulation you wanted.  But mv(1) is specified by POSIX,
and has never done pattern manipulation.  The glob in your second
argument is expanded by the shell independently of the * in the first
argument, and mv never knows that either variant was a glob.

-- 
Eric Blake   eblake <at> redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

[signature.asc (application/pgp-signature, attachment)]

This bug report was last modified 13 years and 326 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.