bug-bash
[Top][All Lists]
Advanced

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

Re: mv to a non-existent path now renames instead of failing


From: Eric Blake
Subject: Re: mv to a non-existent path now renames instead of failing
Date: Thu, 17 Mar 2016 09:00:37 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0

On 03/17/2016 08:49 AM, Eric Blake wrote:

>> Repeat-By:
>>      rmdir two 2> /dev/null
>>      mkdir one
>>      mv one two/
> 
> POSIX requires this to succeed, and renames 'one/' to 'two/'.

That said, if you WANT an error if 'two/' does not exist, and to move
'one' to 'two/one' if 'two/' does exist, you can always use:

mv one two/.

where the trailing '.' changes the semantics required of the rename()
call, and forces an error if 'two/' does not exist.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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