[darcs patch] filepath: normalise trailing dot

Hi, the attached darcs patch modifies the behaviour of normalise to handle trailing dots in a path. The previous behaviour yielded this: Prelude System.FilePath> normalise "../." "../." Prelude System.FilePath> normalise ".././" ".././" Prelude System.FilePath> normalise ".././.." "../.." This patch modifies dropDots such that the check for (".":[]) only occurs once for the path, after which a driver function dropDots' is used which skips this check. Hence "." can be removed from the end of a longer path, but a path of just "." is unchanged. (my trac account is pending verification, I'll reply with a trac ticket # later if needed) cheers, Conrad.

Hi Conrad,
Your proposal seems sensible (+1). Although in the past some people
complained about normalising away .'s being a bug in some corner
cases, so if anyone can find one of them I withdraw my support.
Creating a trac ticket is important so that the patch doesn't get lost.
Thanks, Neil
On Thu, Feb 11, 2010 at 8:22 AM, Conrad Parker
Hi,
the attached darcs patch modifies the behaviour of normalise to handle trailing dots in a path. The previous behaviour yielded this:
Prelude System.FilePath> normalise "../." "../." Prelude System.FilePath> normalise ".././" ".././" Prelude System.FilePath> normalise ".././.." "../.."
This patch modifies dropDots such that the check for (".":[]) only occurs once for the path, after which a driver function dropDots' is used which skips this check. Hence "." can be removed from the end of a longer path, but a path of just "." is unchanged.
(my trac account is pending verification, I'll reply with a trac ticket # later if needed)
cheers,
Conrad.
_______________________________________________ Libraries mailing list Libraries@haskell.org http://www.haskell.org/mailman/listinfo/libraries

On 17 February 2010 01:50, Neil Mitchell
Hi Conrad,
Your proposal seems sensible (+1). Although in the past some people complained about normalising away .'s being a bug in some corner cases, so if anyone can find one of them I withdraw my support.
Creating a trac ticket is important so that the patch doesn't get lost.
Hi, apologies for the high latency, here is a trac ticket: http://hackage.haskell.org/trac/ghc/ticket/3975 Conrad.
Thanks, Neil
On Thu, Feb 11, 2010 at 8:22 AM, Conrad Parker
wrote: Hi,
the attached darcs patch modifies the behaviour of normalise to handle trailing dots in a path. The previous behaviour yielded this:
Prelude System.FilePath> normalise "../." "../." Prelude System.FilePath> normalise ".././" ".././" Prelude System.FilePath> normalise ".././.." "../.."
This patch modifies dropDots such that the check for (".":[]) only occurs once for the path, after which a driver function dropDots' is used which skips this check. Hence "." can be removed from the end of a longer path, but a path of just "." is unchanged.
(my trac account is pending verification, I'll reply with a trac ticket # later if needed)
cheers,
Conrad.
_______________________________________________ Libraries mailing list Libraries@haskell.org http://www.haskell.org/mailman/listinfo/libraries

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"
Discussion period: 2 weeks
cheers,
Conrad.
On 11 April 2010 10:08, Conrad Parker
On 17 February 2010 01:50, Neil Mitchell
wrote: Hi Conrad,
Your proposal seems sensible (+1). Although in the past some people complained about normalising away .'s being a bug in some corner cases, so if anyone can find one of them I withdraw my support.
Creating a trac ticket is important so that the patch doesn't get lost.
Hi,
apologies for the high latency, here is a trac ticket:
http://hackage.haskell.org/trac/ghc/ticket/3975
Conrad.
Thanks, Neil
On Thu, Feb 11, 2010 at 8:22 AM, Conrad Parker
wrote: Hi,
the attached darcs patch modifies the behaviour of normalise to handle trailing dots in a path. The previous behaviour yielded this:
Prelude System.FilePath> normalise "../." "../." Prelude System.FilePath> normalise ".././" ".././" Prelude System.FilePath> normalise ".././.." "../.."
This patch modifies dropDots such that the check for (".":[]) only occurs once for the path, after which a driver function dropDots' is used which skips this check. Hence "." can be removed from the end of a longer path, but a path of just "." is unchanged.
(my trac account is pending verification, I'll reply with a trac ticket # later if needed)
cheers,
Conrad.
_______________________________________________ Libraries mailing list Libraries@haskell.org http://www.haskell.org/mailman/listinfo/libraries

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). -Isaac

On 1 December 2010 15:03, Isaac Dupree
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

On 3 December 2010 15:19, Conrad Parker
On 1 December 2010 15:03, Isaac Dupree
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
* 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/"
Hi, as there's been no further discussion on this during the requested period, I've marked the ticket for review. cheers, Conrad.

On 18/12/2010 03:30, Conrad Parker wrote:
On 3 December 2010 15:19, Conrad Parker
wrote: On 1 December 2010 15:03, Isaac Dupree
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
* 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/"
Hi,
as there's been no further discussion on this during the requested period, I've marked the ticket for review.
This is a change in behaviour, so presumably there should be a version number bump too? Neil? Cheers, Simon
participants (4)
-
Conrad Parker
-
Isaac Dupree
-
Neil Mitchell
-
Simon Marlow