Skip to content

Commit

Permalink
Add readlink (#377)
Browse files Browse the repository at this point in the history
Fixes #376
  • Loading branch information
Gabriella439 authored Mar 10, 2020
1 parent 51fb4bc commit a03df3f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
4 changes: 0 additions & 4 deletions release.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
let
ghc822 = import ./default.nix { compiler = "ghc822"; };

default = import ./default.nix { };

in
Expand All @@ -9,8 +7,6 @@ in
{ name = "all";

constituents = [
ghc822.turtle

default.turtle
];
};
Expand Down
9 changes: 9 additions & 0 deletions src/Turtle/Prelude.hs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ module Turtle.Prelude (
, cd
, pwd
, home
, readlink
, realpath
, mv
, mkdir
Expand Down Expand Up @@ -943,6 +944,14 @@ pwd = liftIO Filesystem.getWorkingDirectory
home :: MonadIO io => io FilePath
home = liftIO Filesystem.getHomeDirectory

-- | Get the path pointed to by a symlink
readlink :: MonadIO io => FilePath -> io FilePath
readlink =
fmap Filesystem.decodeString
. liftIO
. System.Directory.getSymbolicLinkTarget
. Filesystem.encodeString

-- | Canonicalize a path
realpath :: MonadIO io => FilePath -> io FilePath
realpath path = liftIO (Filesystem.canonicalizePath path)
Expand Down
3 changes: 1 addition & 2 deletions turtle.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ License-File: LICENSE
Copyright: 2015 Gabriel Gonzalez
Author: Gabriel Gonzalez
Maintainer: [email protected]
Tested-With: GHC == 7.10.2, GHC == 8.0.1
Bug-Reports: https://github.com/Gabriel439/Haskell-Turtle-Library/issues
Synopsis: Shell programming, Haskell-style
Description: @turtle@ is a reimplementation of the Unix command line environment
Expand Down Expand Up @@ -55,7 +54,7 @@ Library
bytestring >= 0.9.1.8 && < 0.11,
clock >= 0.4.1.2 && < 0.9 ,
containers >= 0.5.0.0 && < 0.7 ,
directory >= 1.0.7 && < 1.4 ,
directory >= 1.3.1.0 && < 1.4 ,
exceptions >= 0.4 && < 0.11,
foldl >= 1.1 && < 1.5 ,
hostname < 1.1 ,
Expand Down

0 comments on commit a03df3f

Please sign in to comment.