0
0
mirror of https://github.com/tj/n.git synced 2024-12-01 14:41:07 +01:00
This commit is contained in:
JunJian Zheng 2015-10-16 21:30:55 +08:00
parent 1388dd0926
commit 8582e0e7e2

12
bin/n
View File

@ -359,9 +359,17 @@ erase_line() {
is_ok() { is_ok() {
if command -v curl > /dev/null; then if command -v curl > /dev/null; then
$GET -Is $1 | head -n 1 | grep 200 > /dev/null if $GET -Is $1 | head -n 1 | grep '3..' > /dev/null; then
is_ok $GET -Is $1 | grep Location | awk -F ': ' '{print $2}'
else
$GET -Is $1 | head -n 1 | grep 200 > /dev/null
fi
else else
$GET -S --spider 2>&1 $1 | head -n 1 | grep 200 > /dev/null if $GET -S --spider 2>&1 $1 | head -n 1 | grep 200 > /dev/null; then
is_ok $GET -S --spider 2>&1 $1 | grep Location | awk -F ': ' '{print $2}'
else
$GET -S --spider 2>&1 $1 | head -n 1 | grep 200 > /dev/null
fi
fi fi
} }