Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Some commands (such as `make`) take a long time to run. While waiting, you will
**Contributions are welcomed!**

## prerequisites
**only tested on debian**
**only tested on debian and macOS**
- python 3.x
- curl
- bash
Expand Down
22 changes: 19 additions & 3 deletions task-notify.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,22 @@ gather_stderr() {
tee /dev/stderr > "$LOGDIR/stderr"
}

if [[ "$(uname)" == "Darwin" ]]; then
showts() {
"$PYTHON" -c "import time;print(time.time())"
}
timescript() {
time script -e "$3" "$1"
}
else
showts() {
date '+%s.%N'
}
timescript() {
time script -e -c "$1" -t"$2" "$3"
}
fi

run() {
if [[ ! $USE_TTY = 0 ]]; then
declare -a cmd=("$@")
Expand All @@ -60,7 +76,7 @@ run() {
} > "$LOGDIR/command.sh"
chmod +x "$LOGDIR/command.sh"
{
time script -e -c "$LOGDIR/command.sh" -t"$LOGDIR/timing" "$LOGDIR/output"
timescript "$LOGDIR/command.sh" "$LOGDIR/timing" "$LOGDIR/output"
} 2>"$LOGDIR/time"
return $?
else
Expand All @@ -73,12 +89,12 @@ run() {
fi
}

date '+%s.%N' > "$LOGDIR/start"
showts > "$LOGDIR/start"

run "$@"
CODE=$?

date '+%s.%N' > "$LOGDIR/end"
showts > "$LOGDIR/end"

cat "$LOGDIR/time"

Expand Down