Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: A change with the -n option for cp in Mac OS X 10.5



On Nov 5, 2007, at 11:39 AM, Eric Gorr wrote:

Is this the right place for this question?

Yes.

Under 10.4.10, when executing cp -n, cp would return an exit status of 0 if the file you told it to copy existed or not.

Under 10.5, cp will return an exit status of 1 if the file already exists and one uses the -n option.

I was just wondering if:

1. 10.4.10 had a bug
2. 10.5 has a bug
3. the definition of how the -n option is supposed to work has changed

It seems strange that cp would return an exit status of 1 now if the file already exists. After all, the command will do exactly what it is supposed to do and not copy the file.

I suppose it was #3. It looks like the exit status was changed due to feedback that returning a zero exit status gives no way to determine whether or not a file was actually copied (<rdar://problem/3624563>). This is a divergence from the FreeBSD behavior in 10.4.10 (FreeBSD introduced the non-standard -n flag). Because -n is non-standard[1], I'd recommend against using it.


- Kevin

[1] <http://www.opengroup.org/onlinepubs/009695399/utilities/cp.html>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/darwin-dev/email@hidden

This email sent to email@hidden
References: 
 >A change with the -n option for cp in Mac OS X 10.5 (From: Eric Gorr <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.