in reply to Re^2: How does rename() work on read-only files?
in thread How does rename() work on read-only files?

I expect that the new inode numbers for alpha/foo* in the linked doc are in error. The textual description in the doc is correct:

So what happens?  Consider this

    perl -i.bak -pe 1 alpha/foo

Perl wants to do this

    rename alpha/foo to alpha/foo.bak
    create a new alpha/foo

Now, alpha/foo is permission 0644, which means you can write it, *BUT
THIS IS IRRELEVANT*.  You are not altering the file.  You moved it out
of the way and created a new one.  Moving and creating are governed by
the directory's permissions.  Since alpha is mode 0755, this is allowed ...

The fact that tchrist's file-dir-perms doc is now relegated to a tarball in the olddoc tree does suggest that it is only kept for historical interest, despite the link from perlfaq5.

Replies are listed 'Best First'.
Re^4: How does rename() work on read-only files?
by j41r (Beadle) on Dec 12, 2018 at 00:28 UTC
    The fact that tchrist's file-dir-perms doc is now relegated to a tarball in the olddoc tree does suggest that it is only kept for historical interest, despite the link from perlfaq5.

    Good tidbit hippo! One more question, could you please tell me if that's also a mistake? From file-dir-perms:

    What happens when you try to do this? perl -i.bak -pe 1 alpha/bar Well, you seem to think you shouldn't be able to rename it because it's mode 0555, readonly. But that's irrelevant. It's the diretory that matters. So it succeeds.

    The previous command actually operates on alpha (0755) and on bar (0444). Why did he refer to beta (0555) here?

      It's impossible to be certain. I think it is a mistake, but a different one. Given the textual context I think the mistake is just to quote the perms as 0555 instead of 0444. If that one change were to be made then it would make good sense to me. Would you agree?

        If that one change were to be made then it would make good sense to me. Would you agree?

        Yes, I would.