Compile with CXX=c++ on FreeBSD, as FreeBSD >= 10.0 no longer has
GCC in the base system (c++ is hardlinked to clang++ on FreeBSD 10.0
and g++ on FreeBSD < 10).
FreeBSD's regular expression library does not like the pattern used
for matching explicit version strings in `nvm_ls`. Change the
pattern to something more specific that works on FreeBSD.
The `==` operator is not defined by POSIX and many test(1) (also
spelled `[`) implementations do not support it. Replace uses of
`==` with the POSIX-conformant `=` equality operator.
Add double-quotes around all expr(1) left-hand-sides where the
argument is just a variable, to prevent syntax errors when the
variable is empty.
Also avoid the `expr match ...` variant as this is not defined in
POSIX and causes errors in some implementations, including
FreeBSD's.
The `colorize_version` command fails in dash (default /bin/sh on
Ubuntu) with an error like:
local: v0.2.3: bad variable name
Instead of using a local variable, interpolate the function argument
directly to avoid the error.
Some shells do not have a nullglob feature, including dash (default
/bin/sh on Ubuntu) and the Almquist shell (default /bin/sh on
FreeBSD). An mv(1) command in setup_dir is failing due to a glob
not matching anything, so use a more widely supported construction.
Much of the discussion in the README pertains to zsh as much as
bash, so include a specific reference to ~/.zshrc and remove one
explicit reference to bash.
On FreeBSD, if MANPATH is set it is used verbatim; configuration
files are completely ignored. Therefore, setting MANPATH to (only)
the nvm man dir makes system man pages unreachable.
To get around this, before doing anything else to MANPATH, if it is
empty set it to the output of manpath(1).
One further complication: FreeBSD automatically adds a path to the
man pages path for each path in PATH that ends in "/bin", which
causes "~/.nvm/$VERSION/man" to be added. This interferes with the
subsequent substitution so strip this from MANPATH before the
substitution.