-
Notifications
You must be signed in to change notification settings - Fork 66
Expand file tree
/
Copy pathfunctions.sh
More file actions
41 lines (36 loc) · 824 Bytes
/
functions.sh
File metadata and controls
41 lines (36 loc) · 824 Bytes
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
info() {
echo "+ $@" >&2
}
warning() {
echo "! $@" >&2
}
error() {
echo "* $@" >&2
exit 1
}
npath() {
python -c "import sys, os; print os.path.normpath(os.path.abspath(os.path.join(*sys.argv[1:])))" $@
}
set_downloader() {
downloader=""
[ "$downloader" == "" ] && which curl >&/dev/null && downloader="curl"
[ "$downloader" == "" ] && which wget >&/dev/null && downloader="wget"
case $downloader in
curl)
function downloader { curl -LO "$1"; }
;;
wget)
function downloader { wget "$1"; }
;;
*)
error "no downloader found (either curl or wget)"
;;
esac
}
readconfig() {
local x
for x in $@
do
[ -f "$x" ] && { info "loading config from $x"; . "$x" ; }
done
}