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.
In the absense of shasum(1) (which on FreeBSD is provided by Perl,
from ports) nvm falls back to sha1sum(1) which does not exist on
FreeBSD. But FreeBSD does have sha1(1) so look for sha1(1) and use
it if present.
As part of this change, refactor the execution of the checksum
program down into nvm_checksum and also clean up some special-casing
of empty dist checksums, which is already handled by nvm_checksum.
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.
The same fix as #207, just for fools like me who have `which` aliased to `type` in OS X. Without this escape, a very cryptic error message is emitted (though the install ultimately succeeds, as long as one actually has `curl` installed).
Fixes issues #232 and #244 where "nvm ls" returns inconsistent results depending on the number of node versions installed. This updated fix uses the find and sort commands only. Tested in bash v3.2.48 and v4.2.25, and zsh v4.3.11.
Fixes issue 232 that occurs in at least bash v4.2.25 where "nvm ls" returns "N/A" no matter how many versions of node have been installed. The fix uses a combination of the find, tr and basename commands instead of basename only. Tested in bash v3.2.48 and v4.2.25 and zsh v4.3.11.
basename doesn't accept options in bash. This causes the VERSIONS variable get the 'N/A' value for $ nvm ls command.
From basename man page:
NAME
basename - strip directory and suffix from filenames
SYNOPSIS
basename NAME [SUFFIX]
basename OPTION
DESCRIPTION
Print NAME with any leading directory components removed. If specified, also remove a trailing SUFFIX.
--help display this help and exit
--version
output version information and exit
coreutils version used in Linux Mint 14 Nadia.
GNU coreutils 8.12.197-032bb September 2011 BASENAME(1)
No idea if this flag exists on FreeBSD or other unixes (if they use gnu coreutils shouldn't be any problem)
Since we run in interactive context the builtin `cd' may have been aliased to
print some additional info when invoked, thus it's safer for us to avoid
parsing the output from subshells which calls it.
For instance in .bash_profile I have the following function to redefine
`cd' such that it will list the destination directory contents:
cd () { builtin cd "$@" && ls -F --color=auto }
line 188, `which shasum > /dev/null 2>&1` will be replaced by:
'/usr/bin/shasum > /dev/null 2>&1'
but, `/usr/bin/shasum` needs filename argument which is ommited and the
test results always 'false'.
Fixes issue #39
ZSH's default globbing behaviour differs from Bash. If there is no
match, ZSH itself will print the error message.
This means that piping a commantd's STDERR to /dev/null will not
hide it.
By unsetting the NOMATCH option we get a behaviour similar to Bash.
Signed-off-by: Tomas Sedovic <tomas@sedovic.cz>
This fixes issue with curl not being installed before nvm is initially sourced
and then curl subsequently being installed.
removed creation of global curl function (after error detected) which
overwrites the system tool, preventing execution of later installed
curl binary
When sourcing nvm.sh, if there are no version of node installed the command
`nvm ls default` silentry fails, however it's return status code (`$?`) is
still set to non-zero, which means an error.
This patch simply avoids this issue by making sure the status code after
sourcing is ok so that people that put the returned status codes in their
command line prompt don't get an error every time `nvm.sh` is sourced.
Now sorts correctly in all instances and prints highlights
even in sorted views. Also will output a list of matching versions
for commands of the form nvm ls 0.4* rather than just printing one
version. nvm version 0.4 still prints the single latest matching
version, however.
Trying to install already installed version causes misleading message
from curl and nvm:
$ nvm install v0.4.11
curl: (33) HTTP server doesn't seem to support byte ranges. Cannot
resume.
nvm: install v0.4.11 failed!
Of course, resuming interrupted installs is still possible (script
checks for existance of `$VERSION` in `$NVM_DIR`, not `$NVM_DIR/src`).