* dpuu <[EMAIL PROTECTED]> [2008-11-21 19:00]: > The definition of C<chown> includes the statement that it's not > available on most system unless you're superuser; and this can > be checked using a POSIX incantation. I was wondering if it > would be reasonable to provide this as a method on the chown > function, so that a user could say: > > if &chown.is_restricted { > ... > } > else { > chown $user, $group <== @files > }
As has been mentioned by others this is a bad idea. All atomic operations on filesystems boil down to attempting an operation and dealing with the fallout if it fails. Attempting to check whether an operation will succeed prior to attempting it almost invariably leads to broken code. (Worse: subtly broke code, in most cases.) The API you propose does not seem to me to shorten code at all and is likely to lead to problematic code, so it seems like a bad idea. Interfaces should be designed to encourage people to do things correctly and to make it hard to even think about the nearly certainly wrong way. Regards, -- Aristotle Pagaltzis // <http://plasmasturm.org/>