haskell/cabal — pull request #1756 by benarmston (2014-04-06 22:51:39+00:00)
Title: Cabal exec command

This PR contains a working implementation of `cabal exec`. The executed subprocess runs in an environment which has the sanbox bin dir added to PATH and GHC_PACKAGE_PATH contains both the sandbox db and the global db.

In its current state, too much code and dependencies have been added to `Main.hs` which would be better factored out to some other module. But before I do that, I'd like to canvas some feedback on some basic UI and design decisions.

The command name is `cabal exec` rather than `cabal sandbox exec`. This follows from the initial work done by @etrepum. However, if the package is not sandboxed, the command does not do anything. We should change this so that either the command is called `cabal sandbox exec` or we keep the command as `cabal exec` and it simply executes the provided arguments with no changes in the environment.

The global package path is obtained by running `ghc --print-global-package-db` and parsing the output. The function for doing this has been added to `Distribution.Simple.GHC`. Is it OK to add functions to `Cabal` which are required only by `cabal-install`? Is it OK to introduce a dependency on the simple build system for this feature?

What options should `cabal exec` (or `cabal sandbox exec`) take?