зеркало из https://github.com/golang/dep.git
Merge pull request #1730 from 0xmohit/fix-install-script
fix install script when curl is not available
This commit is contained in:
Коммит
afd48a0604
15
install.sh
15
install.sh
|
@ -23,14 +23,15 @@ downloadJSON() {
|
|||
url="$2"
|
||||
|
||||
echo "Fetching $url.."
|
||||
if type curl > /dev/null; then
|
||||
if test -x "$(command -v curl)"; then
|
||||
response=$(curl -s -L -w 'HTTPSTATUS:%{http_code}' -H 'Accept: application/json' "$url")
|
||||
body=$(echo "$response" | sed -e 's/HTTPSTATUS\:.*//g')
|
||||
code=$(echo "$response" | tr -d '\n' | sed -e 's/.*HTTPSTATUS://')
|
||||
elif type wget > /dev/null; then
|
||||
elif test -x "$(command -v wget)"; then
|
||||
temp=$(mktemp)
|
||||
body=$(wget -q --header='Accept: application/json' -O - --server-response --content-on-error "$url" 2> "$temp")
|
||||
code=$(awk '/^ HTTP/{print $2}' < "$temp")
|
||||
body=$(wget -q --header='Accept: application/json' -O - --server-response "$url" 2> "$temp")
|
||||
code=$(awk '/^ HTTP/{print $2}' < "$temp" | tail -1)
|
||||
rm "$temp"
|
||||
else
|
||||
echo "Neither curl nor wget was available to perform http requests."
|
||||
exit 1
|
||||
|
@ -48,10 +49,10 @@ downloadFile() {
|
|||
destination="$2"
|
||||
|
||||
echo "Fetching $url.."
|
||||
if type curl > /dev/null; then
|
||||
if test -x "$(command -v curl)"; then
|
||||
code=$(curl -s -w '%{http_code}' -L "$url" -o "$destination")
|
||||
elif type wget > /dev/null; then
|
||||
code=$(wget -q -O "$destination" --server-response "$url" 2>&1 | awk '/^ HTTP/{print $2}')
|
||||
elif test -x "$(command -v wget)"; then
|
||||
code=$(wget -q -O "$destination" --server-response "$url" 2>&1 | awk '/^ HTTP/{print $2}' | tail -1)
|
||||
else
|
||||
echo "Neither curl nor wget was available to perform http requests."
|
||||
exit 1
|
||||
|
|
Загрузка…
Ссылка в новой задаче