FIX #1839, #1463, by supporting ghc-pkg bulk queries with substring matching
authorclaus.reinke@talk21.com <unknown>
Mon, 21 Jan 2008 16:17:44 +0000 (16:17 +0000)
committerclaus.reinke@talk21.com <unknown>
Mon, 21 Jan 2008 16:17:44 +0000 (16:17 +0000)
commit68f7cd160712d9666a492703f7d4a89ad7e9158c
treedc002b870c8463faebf19ef0c9db423870715672
parent64bfc0114c0811fe175149dd6d803c7c77de0062
FIX #1839, #1463, by supporting ghc-pkg bulk queries with substring matching

   - #1839 asks for a ghc-pkg dump feature, #1463 for the ability
     to query the same fields in several packages at once.

   - this patch enables substring matching for packages in 'list',
     'describe', and 'field', and for modules in find-module. it
     also allows for comma-separated multiple fields in 'field'.
     substring matching can optionally ignore cases to avoid the
     rather unpredictable capitalisation of packages.

   - the patch is not quite as full-featured as the one attached
     to #1839, but avoids the additional dependency on regexps.
     open ended substrings are indicated by '*' (only the three
     forms prefix*, *suffix, *infix* are supported)

   - on windows, the use of '*' for package/module name globbing
     leads to conflicts with filename globbing: by default, windows
     programs are self-globbing, and bash adds another level of
     globbing on top of that. it seems impossible to escape '*'
     from both levels of globbing, so we disable default globbing
     for ghc-pkg and ghc-pkg-inplace. users of bash will still
     have filename globbing available, users of cmd won't.

   - if it is considered necessary to reenable filename globbing
     for cmd users, it should be done selectively, only for
     filename parameters. to this end, the patch includes a
     glob.hs program which simply echoes its parameters after
     filename globbing. see the commented out glob command in
     Main.hs for usage or testing.

   - this covers both tickets, and permits for the most common
     query patterns (finding all packages contributing to the
     System. hierarchy, finding all regex or string packages,
     listing all package maintainers or haddock directories,
     ..), which not only i have wanted to have for a long time.

     examples (the quotes are needed to escape shell-based
     filename globbing and should be omitted in cmd.exe):

       ghc-pkg list '*regex*' --ignore-case
       ghc-pkg list '*string*' --ignore-case
       ghc-pkg list '*gl*' --ignore-case
       ghc-pkg find-module 'Data.*'
       ghc-pkg find-module '*Monad*'
       ghc-pkg field '*' name,maintainer
       ghc-pkg field '*' haddock-html
       ghc-pkg describe '*'
utils/ghc-pkg/Main.hs
utils/ghc-pkg/Makefile