gvmtool/gvm — pull request #79 by pledbrook (2012-11-27 11:33:31+00:00)
Title: Add initial support for per-shell versions: issue #52

In order to make version changes only apply to the current shell, I had to make
the `gvm-init.sh` script source the `gvm` one. This meant replacing all `exit`
calls in the later with `return`s and changing the name of the functions by
prefixing them with `__gvmtool_` (to avoid the functions appearing in bash
auto-completion by accident).

To help with some of the internals, `gvm-init.sh` now exports the `GVM_DIR`
variable if it hasn't already been set by the user. This makes it availabe to
`gvm` and any plugin scripts that get executed in sub-shells.

`gvm-init.sh` also sources any scripts in `$GVM_DIR/plugins` whose name begins
with `sourced-` and ends with `.sh`. This allows users to extend the system
with extra functionality, although they are required to name their functions
with `__gvmtool_`. Plugins can also be implemented as straight
`gvm-.sh` scripts, but these manually need to source the `gvm` script
if they want access to its internal functions, such as `__gvmtool_help`.

One thing that remains unresolved is whether to support the symlink approach
as well, and if so, how. Another issue is how to determine what happens at
switch time. At the moment, the script just assumes that it needs to change
the value of the `${CANDIDATE}_HOME` environment variable, but is that the
case for all candidates? Probably not.