Opened 6 years ago

Closed 4 years ago

Last modified 4 years ago

#2034 closed proposal (fixed)

In FilePath, current directory should be ".", not ""

Reported by: igloo Owned by: neil
Priority: normal Milestone: Not GHC
Component: libraries (other) Version: 6.8.1
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:

Description

FilePath's "current directory" should be ".", not "". This affects a number of commands, e.g.

normalise "."       should be "."         not ""
"." </> "foo"       should be "foo"       not "./foo"
splitFileName "foo" should be (".","foo") not ("","foo")

Some discussion is in this thread:
http://www.haskell.org/pipermail/libraries/2007-December/008743.html

Attachments (2)

2034.patch (6.0 KB) - added by simonmar 5 years ago.
2034-version2.patch (8.0 KB) - added by simonmar 5 years ago.

Download all attachments as: .zip

Change History (13)

comment:1 Changed 6 years ago by NeilMitchell

I will tackle this later today.

comment:2 Changed 6 years ago by simonmar

  • Architecture changed from Unknown to Unknown/Multiple

comment:3 Changed 6 years ago by simonmar

  • Operating System changed from Unknown to Unknown/Multiple

comment:4 Changed 5 years ago by igloo

  • Milestone changed from 6.10 branch to 6.12.1

Changed 5 years ago by simonmar

comment:5 Changed 5 years ago by simonmar

  • Type changed from bug to proposal

Changed 5 years ago by simonmar

comment:6 Changed 5 years ago by simonmar

Patch version 2 added, after discussion on the libraries list. The new patch description is:

Wed Nov  4 09:51:09 GMT 2009  Simon Marlow <marlowsd@gmail.com>
  * The current directory is ".", not "" (GHC bug #2034) (patch version 2)
    
  So now
          splitFileName "foo" = ("./", "foo")
  
  which gives us the additional property that
  
  > Valid x => isValid (fst (splitFileName x))
  
  This property is important, because it means that we can pass the
  result of takeDirectory to any of the functions in System.Directory,
  whereas previously we would have to check for the empty case first.
  
  After discussion on the libraries list, I removed the second part of
  the original change:
  
          "." </> x = x
  
  This small bit of normalisation was there to ensure that the property
  
  > Valid x => uncurry </> (splitFileName x) == x
  
  still held.  However, it was arguably inconsistent (see the
  discussion).  Now this property has an exception:
  
  > Valid x => uncurry (</>) (splitFileName x) == x || fst (splitFileName x) == "./"
  
  This is a small price to pay to gain the new property above.

comment:7 Changed 5 years ago by igloo

Note the patch was applied and rolled back, so darcs will think it's already applied.

comment:8 Changed 5 years ago by igloo

  • Type of failure set to None/Unknown

See also #3276

comment:9 Changed 5 years ago by igloo

  • Milestone changed from 6.12.1 to Not GHC

comment:10 Changed 4 years ago by simonmar

  • Resolution set to fixed
  • Status changed from new to closed

Pushed, and filepath version bumped to 1.2.0.0:

Wed Nov  4 09:51:09 GMT 2009  Simon Marlow <marlowsd@gmail.com>
  * The current directory is ".", not "" (GHC bug #2034) (patch version 2)
    
  So now
          splitFileName "foo" = ("./", "foo")
  
  which gives us the additional property that
  
  > Valid x => isValid (fst (splitFileName x))
  
  This property is important, because it means that we can pass the
  result of takeDirectory to any of the functions in System.Directory,
  whereas previously we would have to check for the empty case first.
  
  After discussion on the libraries list, I removed the second part of
  the original change:
  
          "." </> x = x
  
  This small bit of normalisation was there to ensure that the property
  
  > Valid x => uncurry </> (splitFileName x) == x
  
  still held.  However, it was arguably inconsistent (see the
  discussion).  Now this property has an exception:
  
  > Valid x => uncurry (</>) (splitFileName x) == x || fst (splitFileName x) == "./"
  
  This is a small price to pay to gain the new property above.
Shall I push this patch? (1/3)  [ynWsfvplxdaqjk], or ? for help: y
Wed May  5 10:52:12 BST 2010  Simon Marlow <marlowsd@gmail.com>
  * bump to 1.2.0.0, after semantics change (current dir is now ".", not "")
Shall I push this patch? (2/3)  [ynWsfvplxdaqjk], or ? for help: y
Wed May  5 10:58:43 BST 2010  Simon Marlow <marlowsd@gmail.com>
  * warning suppression

comment:11 Changed 4 years ago by robertmassaioli

This change was certainly for the better but it took me a while to figure out that it was causing a problem in the line:

validFilePaths = filterM (doesDirectoryExist . dropFileName)

In the code here: https://github.com/robertmassaioli/htee/blob/master/Main.hs

Note: See TracTickets for help on using tickets.