forked from intel/lkp-tests
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwget.sh
executable file
·52 lines (41 loc) · 1.12 KB
/
wget.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/sh
setup_wget()
{
local wget
wget=$(cmd_path wget) || return
# wget command may link to busybox which not support --local-encoding
# etc. options
[ -L "$wget" ] && return 1
http_client_cmd="$wget -q --timeout=1800 --tries=1"
local wget_help="$($http_client_cmd --help 2>&1)"
[ "$wget_help" != "${wget_help#*--local-encoding}" ] && {
local iri_not_support="This version does not have support for IRIs"
# $ /usr/bin/wget --local-encoding=UTF-8 /tmp/abcde
# This version does not have support for IRIs
$http_client_cmd --local-encoding=UTF-8 /tmp/abcde 2>&1 | grep -qF "$iri_not_support" || http_client_cmd="$http_client_cmd --local-encoding=UTF-8"
}
return 0
}
[ -n "$http_client_cmd" ] || setup_wget || return
http_get_file()
{
check_create_base_dir "$2"
http_escape_request "$1" -O "$2"
}
http_get_directory()
{
local dir=$2
mkdir -p $dir
# download directory recursively
http_do_request "$1" -c -r -np -nd -P "$dir"
}
http_get_newer()
{
local path="$(dirname "$2")"
http_escape_request "$1" -N -P "$path"
}
http_get_cgi()
{
check_create_base_dir "$2"
http_do_request "$1" -O "${2:-/dev/null}"
}