From a03df3f5775efcdc45d5ef8f15d289b4ac2be8fc Mon Sep 17 00:00:00 2001 From: Gabriel Gonzalez Date: Tue, 10 Mar 2020 07:53:26 -0700 Subject: [PATCH] Add `readlink` (#377) Fixes https://github.com/Gabriel439/Haskell-Turtle-Library/issues/376 --- release.nix | 4 ---- src/Turtle/Prelude.hs | 9 +++++++++ turtle.cabal | 3 +-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/release.nix b/release.nix index d51af8a..6e16e8e 100644 --- a/release.nix +++ b/release.nix @@ -1,6 +1,4 @@ let - ghc822 = import ./default.nix { compiler = "ghc822"; }; - default = import ./default.nix { }; in @@ -9,8 +7,6 @@ in { name = "all"; constituents = [ - ghc822.turtle - default.turtle ]; }; diff --git a/src/Turtle/Prelude.hs b/src/Turtle/Prelude.hs index 8262398..adcee09 100644 --- a/src/Turtle/Prelude.hs +++ b/src/Turtle/Prelude.hs @@ -121,6 +121,7 @@ module Turtle.Prelude ( , cd , pwd , home + , readlink , realpath , mv , mkdir @@ -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) diff --git a/turtle.cabal b/turtle.cabal index f4e8416..7f7c944 100644 --- a/turtle.cabal +++ b/turtle.cabal @@ -7,7 +7,6 @@ License-File: LICENSE Copyright: 2015 Gabriel Gonzalez Author: Gabriel Gonzalez Maintainer: Gabriel439@gmail.com -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 @@ -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 ,