forked from zeek/btest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbtest-progress
executable file
·50 lines (40 loc) · 884 Bytes
/
btest-progress
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
#! /usr/bin/env bash
function usage {
cat <<EOF >&2
usage: $(basename "$0") [-q] [-T] <message>
-q: Do not print message to standard output or standard error.
-T: Do not include timestamp on standard error message.
EOF
exit 1
}
### Main.
quiet=0
time=1
while getopts ":qT" opt; do
case $opt in
q)
quiet=1
shift
;;
T)
time=0
shift
;;
*)
usage
;;
esac
done
test $# != 0 || usage
msg="[btest] -- $*"
if [ "${quiet}" -eq 0 ]; then
echo "${msg}"
if [ "${time}" -eq 0 ]; then
echo "${msg}" >&2
else
echo "${msg} -- $(date -u +'%Y-%m-%dT%H:%M:%S.%3NZ') " >&2
fi
fi
TIME=$(python3 -c 'import time; print(time.time_ns())')
file=$(mktemp ".progress.${TIME}.XXXXXX") || exit 1
echo "$@" >>"${file}"