class RVM::Shell::AbstractWrapper

Provides the most common functionality expected of a shell wrapper. Namely, implements general utility methods and tools to extract output from a given command but doesn’t actually run any commands itself, leaving that up to concrete implementations.

Usage

Commands are run inside of a shell (usually bash) and can either be exectuted in two situations (each with wrapper methods available) - silently or verbosely.

Silent commands (via run_silently and run_command) do exactly as they say - that can modify the environment etc but anything they print (to stdout or stderr) will be discarded.

Verbose commands will run the command and then print the command epilog (which contains the output stastus and the current env in yaml format). This allows us to not only capture all output but to also return the exit status and environment variables in a way that makes persisted shell sessions possible.

Under the hood, run and run_silently are the preferred ways of invoking commands - if passed a single command, they’ll run it as is (much like system in ruby) but when given multiple arguments anything after the first will be escaped (e.g. you can hence pass code etc). run will also parse the results of this epilog into a usable RVM::Shell::Result object.

run_command and run_command_silently do the actual hard work for these behind the scenes, running a string as the shell command. Hence, these two commands are what must be implemented in non-abstract wrappers.

For an example of the shell wrapper functionality in action, see RVM::Environment which delegates most of the work to a shell wrapper.