[darcs patch] filepath: normalise trailing dot

Conrad Parker conrad at metadecks.org
Fri Dec 3 07:19:03 CET 2010


On 1 December 2010 15:03, Isaac Dupree <ml at isaac.cedarswampstudios.org> wrote:
> On 11/30/10 23:59, Conrad Parker wrote:
>>
>> Hi,
>>
>> I've re-opened ticket #3975 related to this proposal.
>>
>> It's a fairly minor patch which ensures that filepaths containing a
>> trailing dot are normalised consistently, ie. the path "foo/bar/." is
>> normalised to "foo/bar"
>
> Normalize to "foo/bar/" so that it still forces to resolve symlinks and
> yield a directory.  For example, lstat(), -- you can see the difference by
> shell `stat foo/bar/` and `stat foo/bar` when bar is a symlink -- or
> unlink()/rm.  (Or when bar is a plain non-directory file: slash-->deserved
> error.)  I'm not aware that removing the dot itself has any effect here,
> though. (counterexamples welcome).

Good point: it would be better to normalise "foo/bar/." to "foo/bar/"
not "foo/bar"

I've uploaded a new patch for this ticket which retains the trailing
pathSeparator for directories.

Ticket: http://hackage.haskell.org/trac/ghc/ticket/3975

Patch v2 description:
-----
Fri Dec  3 15:04:44 JST 2010  Conrad Parker <conrad at metadecks.org>
  * normalise trailing dot

  This is version 2 of a patch for ticket #3975

  This patch modifles normalise to treat paths with a trailing dot as the
  corresponding directory: the trailing . is stripped, and the pathSeparator
  is appended to the result of joining path components.

  The special case of all path components being "." is handled first, replacing
  the existing special case test for paths with a leading dot. Dots are now
  dropped consistently for all path components.

  Additional tests are provided for:

      normalise "./." == "./"
      normalise "bob/fred/." == "bob/fred/"

-----

cheers,

Conrad.



More information about the Libraries mailing list