From 63c70ee74b898df8f5581d0762a1929d93494ca1 Mon Sep 17 00:00:00 2001
From: Julian Ospald <hasufell@posteo.de>
Date: Mon, 13 Jul 2020 23:10:17 +0200
Subject: [PATCH] Fix changelog subcommand on darwin

---
 app/ghcup/BrickMain.hs | 6 +++++-
 app/ghcup/Main.hs      | 7 ++++++-
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/app/ghcup/BrickMain.hs b/app/ghcup/BrickMain.hs
index 307f353f..20d01c4f 100644
--- a/app/ghcup/BrickMain.hs
+++ b/app/ghcup/BrickMain.hs
@@ -283,7 +283,11 @@ changelog' AppState {..} (_, ListResult {..}) = do
     Nothing -> pure $ Left
       [i|Could not find ChangeLog for #{lTool}, version #{prettyVer lVer}|]
     Just uri -> do
-      exec "xdg-open" True [serializeURIRef' uri] Nothing Nothing >>= \case
+      let cmd = case _rPlatform pfreq of
+                  Darwin  -> "open"
+                  Linux _ -> "xdg-open"
+                  FreeBSD -> "xdg-open"
+      exec cmd True [serializeURIRef' uri] Nothing Nothing >>= \case
         Right _ -> pure $ Right ()
         Left  e -> pure $ Left [i|#{e}|]
 
diff --git a/app/ghcup/Main.hs b/app/ghcup/Main.hs
index 0d5a3af9..5ddef192 100644
--- a/app/ghcup/Main.hs
+++ b/app/ghcup/Main.hs
@@ -1308,9 +1308,14 @@ Make sure to clean up #{tmpdir} afterwards.|])
                   pure ExitSuccess
                 Just uri -> do
                   let uri' = T.unpack . decUTF8Safe . serializeURIRef' $ uri
+                      cmd = case _rPlatform pfreq of
+                              Darwin  -> "open"
+                              Linux _ -> "xdg-open"
+                              FreeBSD -> "xdg-open"
+
                   if clOpen
                     then
-                      exec "xdg-open"
+                      exec cmd
                            True
                            [serializeURIRef' uri]
                            Nothing
-- 
GitLab