-
Notifications
You must be signed in to change notification settings - Fork 220
/
Copy pathlib.zsh
63 lines (52 loc) · 1.05 KB
/
lib.zsh
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
56
57
58
59
60
61
62
63
## assert_ok <CMD> [ARGS]...
assert-ok() {
local what="$*"
echo "RUN $what"
echo "--------8<--------"
$*
rc=$?
echo "-------->8--------"
if [[ $rc -ne 0 ]]; then
echo "FAIL - exit_status: $rc, command: $what"
echo
exit $rc
else
echo "OK - $what"
fi
}
assert-file-exists() {
local path=$1
if [[ -f $path ]]; then
echo "OK - file exists $path"
else
echo "FAIL - file do not exist: $path"
exit 1
fi
}
assert-file-missing() {
local path=$1
if [[ ! -f $path ]]; then
echo "OK - file missing $path"
else
echo "FAIL - file do exist: $path"
exit 1
fi
}
assert-dir-exists() {
local path=$1
if [[ -d $path ]]; then
echo "OK - dir exists $path"
else
echo "FAIL - dir do not exist: $path"
exit 1
fi
}
assert-dir-missing() {
local path=$1
if [[ ! -d $path ]]; then
echo "OK - dir missing $path"
else
echo "FAIL - dir do exist: $path"
exit 1
fi
}