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.
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.
Using `cd` makes the nvm directory the number-one directory in `autojump`'s database---which is somewhat confusing since the user basically never `cd`s to it directly!---so here's an alternative method that doesn't use the `cd` command. I've checked it works in both Bash and Zsh.
Under certain network environments, due to poor implementation of file
download caches (immoral Chinese ISP), the direct download of Node.js
packages (http://nodejs.org/dist/node-$VERSION.tar.gz) will be
redirected to alternative urls using 302 redirections, which are not
handled by `curl --process-bar` by default. Instead, curl will "fail"
silently without creating any output file or error exitcode.
(Tested under Ubuntu 12.04 Desktop)
Fixed by adding "-L" switches to the curl commands responsible for
downloading the binary and source node.js packages.