Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Fix wget support #125

Closed
wants to merge 2 commits into from

2 participants

@hstkk

N doesn't work without curl:

$ sudo n latest

     install : 0.11.3
/usr/local/bin/n: 209: /usr/local/bin/n: curl: not found

  Error: invalid version 0.11.3
@tjwebb
Collaborator

I'm inclined to consider this if you'd like to merge latest into this PR

@tjwebb
Collaborator

cc @hstkk

@tjwebb tjwebb closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jun 28, 2013
  1. @hstkk

    Fix wget support

    hstkk authored
  2. @hstkk

    Rename GET_OK -> GET_HEADER

    hstkk authored
This page is out of date. Refresh to see the latest.
Showing with 13 additions and 12 deletions.
  1. +13 −12 bin/n
View
25 bin/n
@@ -31,16 +31,17 @@ abort() {
# curl / wget support
GET=
-
-# wget support (Added --no-check-certificate for Github downloads)
-command -v wget > /dev/null && GET="wget --no-check-certificate -q -O-"
-
-# curl support
-command -v curl > /dev/null && GET="curl -# -L"
-
-# Ensure we have curl or wget
-
-test -z "$GET" && abort "curl or wget required"
+GET_HEADER=
+
+if command -v curl > /dev/null; then
+ GET="curl -L#"
+ GET_HEADER="curl -Is"
+elif command -v wget > /dev/null; then
+ GET="wget -O-"
+ GET_HEADER="wget --spider -SqO-"
+else
+ abort "curl or wget required"
+fi
#
# Output usage information.
@@ -206,7 +207,7 @@ erase_line() {
#
is_ok() {
- curl -Is $1 | head -n 1 | grep 200 > /dev/null
+ $GET_HEADER $1 2>&1 | egrep "HTTP.*?200" > /dev/null
}
#
@@ -284,7 +285,7 @@ install_node() {
cd $dir
log fetch $url
- curl -L# $url | tar -zx --strip 1
+ $GET $url | tar -zx --strip 1
erase_line
activate $version
Something went wrong with that request. Please try again.