-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcurlize-wget
55 lines (48 loc) · 979 Bytes
/
curlize-wget
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
53
54
55
#!/bin/sh
# Author: Lanchon
set -e
parse() {
if [[ "$1" == -q ]]; then
shift
parse2 1 "$@"
else
parse2 0 "$@"
fi
}
parse2() {
local quiet="$1"
if [[ $# == 2 ]]; then
parse3 $quiet "$2"
elif [[ $# == 4 ]]; then
if [[ "$2" == -O ]]; then
parse3 $quiet "$4" "$3"
elif [[ "$3" == -O ]]; then
parse3 $quiet "$2" "$4"
fi
fi
}
parse3() {
local quiet="$1"
local src="$2"
local dest="$3"
local dest_opt=-o
if [[ $# == 2 ]]; then
dest=-O
dest_opt=
fi
case "$src" in
"https:"*)
if [[ $quiet = 0 ]]; then
echo "Downloading $src"
fi
if curl -Lfs $dest_opt "$dest" "$src"; then
exit 0
else
>&2 echo "curlize: download error: $src"
exit 1
fi
;;
esac
}
parse "$@"
exec /usr/bin/wget "$@"