[commit: packages/unix] master: Fix error message of `createSymbolicLink`. (fae5cdc)

git at git.haskell.org git at git.haskell.org
Wed Jul 19 22:04:45 UTC 2017


Repository : ssh://git@git.haskell.org/unix

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/fae5cdc103edafb55ef86699dd9571f35b8cf8ed/unix

>---------------------------------------------------------------

commit fae5cdc103edafb55ef86699dd9571f35b8cf8ed
Author: Niklas Hambüchen <mail at nh2.me>
Date:   Wed Feb 8 03:09:00 2017 +0100

    Fix error message of `createSymbolicLink`.
    
    Consider `ln` (or any other Unix tool):
    
        $ ln -s file1 file2
        $ ls -l file2
        lrwxrwxrwx 1 niklas niklas 5 Feb  8 03:09 file2 -> file1
        $ ln -s file1 file2
        ln: failed to create symbolic link 'file2': File exists
    
    The file name mentioned in the error ("link2") is the one
    that *could not be created*, not the content of the pointer.
    
    `createSymbolicLink` got this wrong so far, it would print
    
        file1: createSymbolicLink: already exists (File exists)
    
    which is wrong, this file doesn't already exist.
    
    This commit fixes it.


>---------------------------------------------------------------

fae5cdc103edafb55ef86699dd9571f35b8cf8ed
 System/Posix/Files.hsc            | 2 +-
 System/Posix/Files/ByteString.hsc | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/System/Posix/Files.hsc b/System/Posix/Files.hsc
index bbda084..749f5da 100644
--- a/System/Posix/Files.hsc
+++ b/System/Posix/Files.hsc
@@ -253,7 +253,7 @@ createSymbolicLink :: FilePath -> FilePath -> IO ()
 createSymbolicLink file1 file2 =
   withFilePath file1 $ \s1 ->
   withFilePath file2 $ \s2 ->
-  throwErrnoPathIfMinus1_ "createSymbolicLink" file1 (c_symlink s1 s2)
+  throwErrnoPathIfMinus1_ "createSymbolicLink" file2 (c_symlink s1 s2)
 
 foreign import ccall unsafe "symlink"
   c_symlink :: CString -> CString -> IO CInt
diff --git a/System/Posix/Files/ByteString.hsc b/System/Posix/Files/ByteString.hsc
index 872817e..23a44e3 100644
--- a/System/Posix/Files/ByteString.hsc
+++ b/System/Posix/Files/ByteString.hsc
@@ -259,7 +259,7 @@ createSymbolicLink :: RawFilePath -> RawFilePath -> IO ()
 createSymbolicLink file1 file2 =
   withFilePath file1 $ \s1 ->
   withFilePath file2 $ \s2 ->
-  throwErrnoPathIfMinus1_ "createSymbolicLink" file1 (c_symlink s1 s2)
+  throwErrnoPathIfMinus1_ "createSymbolicLink" file2 (c_symlink s1 s2)
 
 foreign import ccall unsafe "symlink"
   c_symlink :: CString -> CString -> IO CInt



More information about the ghc-commits mailing list