gvmtool/gvm — pull request #82 by pledbrook (2012-12-05 10:42:38+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 latter 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).

Note that this feature is not enabled by default. The user must create a
~/.gvm/gvmconfig file and add 'isolated_mode=1' to it in order to enable the
feature.

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 available to
`gvm` and any plugin scripts that get executed in sub-shells.

`gvm-init.sh` also sources any scripts in `$GVM_DIR/ext` whose name begins
with `sourced-`, allowing users to extend the system with extra functionality
implemented via bash functions. 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`.

In this 'isolated mode', users need some way of setting the default version of
candidates for new shells. So I have also added a new 'set-default' command
that updates the 'current' symlink to the specified candidate version.