[commit: ghc] master: ghc-pkg: Print something when no packages are found; fixes #6119 (55478b1)

Ian Lynagh <[email protected]>
Newsgroups gmane.comp.lang.haskell.cvs.ghc
Message-ID <[email protected]>
Repository : ssh://darcs.haskell.org//srv/darcs/ghc

On branch  : master

http://hackage.haskell.org/trac/ghc/changeset/55478b1ef856d47fba7e7dbd86baa88030d1b1cf

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

commit 55478b1ef856d47fba7e7dbd86baa88030d1b1cf
Author: Ian Lynagh <[email protected]>
Date:   Thu Oct 11 21:31:00 2012 +0100

    ghc-pkg: Print something when no packages are found; fixes #6119
    
    We used to say
    
        $ ghc-pkg list blargle
        /usr/local/lib/ghc-7.4.1/package.conf.d
    
    which may imply that blargle was found in
    /usr/local/lib/ghc-7.4.1/package.conf.d

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

 utils/ghc-pkg/Main.hs |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/utils/ghc-pkg/Main.hs b/utils/ghc-pkg/Main.hs
index d992b54..0f5bd15 100644
--- a/utils/ghc-pkg/Main.hs
+++ b/utils/ghc-pkg/Main.hs
@@ -985,7 +985,10 @@ listPackages verbosity my_flags mPackageName mModuleName = do
       broken = map sourcePackageId (brokenPackages pkg_map)
 
       show_normal PackageDB{ location = db_name, packages = pkg_confs } =
-          hPutStrLn stdout $ unlines ((db_name ++ ":") : map ("    " ++) pp_pkgs)
+          do hPutStrLn stdout (db_name ++ ":")
+             if null pp_pkgs
+                 then hPutStrLn stdout "    (no packages)"
+                 else hPutStrLn stdout $ unlines (map ("    " ++) pp_pkgs)
            where
                  pp_pkgs = map pp_pkg pkg_confs
                  pp_pkg p
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.