[GHC] #7971: doesDirectoryExist description differs from its behavior

GHC ghc-devs at haskell.org
Sat Jun 8 18:20:52 CEST 2013


#7971: doesDirectoryExist description differs from its behavior
----------------------------------------+-----------------------------------
Reporter:  dsf                          |          Owner:                     
    Type:  bug                          |         Status:  new                
Priority:  normal                       |      Component:  libraries/directory
 Version:  7.6.3                        |       Keywords:                     
      Os:  Unknown/Multiple             |   Architecture:  Unknown/Multiple   
 Failure:  Incorrect result at runtime  |      Blockedby:                     
Blocking:                               |        Related:                     
----------------------------------------+-----------------------------------

Comment(by Fuuzetsu):

 Why have you filed a bug for 7.6.3 when you are using 7.6.2? I don't think
 that's an issue here but you should probably be more careful next time.

 Here's my output for 7.6.3
 {{{
 ✓ misaki shana % cd /tmp/7971
 ✓ misaki shana % l
 total 0
 -rw-r--r-- 1 shana games 0 Jun  8 16:39 file
 lrwxrwxrwx 1 shana games 7 Jun  8 16:39 testDirLink -> testDir
 ✓ misaki shana % ghci
 GHCi, version 7.6.3: http://www.haskell.org/ghc/  :? for help
 Loading package ghc-prim ... linking ... done.
 Loading package integer-gmp ... linking ... done.
 Loading package base ... linking ... done.
 Prelude> import System.Directory
 Prelude System.Directory> doesDirectoryExist "testDirLink"
 Loading package filepath-1.3.0.1 ... linking ... done.
 Loading package array-0.4.0.1 ... linking ... done.
 Loading package deepseq-1.3.0.1 ... linking ... done.
 Loading package old-locale-1.0.0.5 ... linking ... done.
 Loading package time-1.4.0.1 ... linking ... done.
 Loading package bytestring-0.10.0.2 ... linking ... done.
 Loading package unix-2.6.0.1 ... linking ... done.
 Loading package directory-1.2.0.1 ... linking ... done.
 False
 Prelude System.Directory>
 }}}

 I had a look at what removeDirectoryRecursive is doing and nothing from
 the source seems to point that it will follow links. It will call ‘unlink’
 on the symlink because doesDirectoryExist will return False and therefore
 will not follow the link. Testing with actual files confirms that calling
 removeDirectoryRecursive that has the link inside of it in fact does not
 do anything beyond removing the linked. Directory linked to is intact.
 Bah, it will never even check if something is the directory unless
 ‘unlink’ fails somehow at which point we get an exception in Either: ‘Left
 e’ and only then we check that something is directory. ‘unlink’ will work
 fine on the symlinks without following them.

 If anything, I think that the ‘Be careful’ message should be investigated.

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/7971#comment:5>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler



More information about the ghc-tickets mailing list