in reply to Re: •Re: [OT] rename(2) -- renaming file to itself produces no error.
in thread [OT] rename(2) -- renaming file to itself produces no error.

Your text leads me to believe that you were attempting this operation merely for the side-effect of updating the mtime on the directory that the file is in. Is this true? If so, shame on you! :)

Otherwise it strikes me as a violation of the principle of least surprise that rename would produce an error when asked to do something that is easy enough to do by doing nothing (principle of least action there)

  • Comment on Re: Re: •Re: [OT] rename(2) -- renaming file to itself produces no error.

Replies are listed 'Best First'.
Re: Re: Re: •Re: [OT] rename(2) -- renaming file to itself produces no error.
by dmitri (Priest) on Jan 07, 2004 at 23:02 UTC
    No, what happened was I was looking over a source tree which I happen (unfortunately) to maintain, and there was a silly rename that was a noop. The return value was checked, but no error was generated. Because no error was generated, this logical error was never detected. So, I got pissed of at rename(2).

    As for the "principle of least action", I explained my position in a previous post, and from the paragraph above you know why I prefer it :)

      Now, why would you be wanting to depend on the system to have to do the thinking for you. For example, if you (or someone you know) have written code that winds up calling rename $old, $new;, where $old eq $new, then I would consider that a flaw in the thought process that went into designing the code, not the fault of the system's rename.

        Yes. And I only found it by actually reading the code. This made wonder about rename(2) behavior.