-
Notifications
You must be signed in to change notification settings - Fork 20
/
btest-ask-update
executable file
·41 lines (37 loc) · 1.12 KB
/
btest-ask-update
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
#! /usr/bin/env bash
#
# Helper script that asks whether the user wants to update a baseline.
#
# Return code:
#
# 0: Yes, update and continue.
# 1: No, don't update but continue.
# 200: No, don't update and abort.
while true; do
printf "\033[0K" >>/dev/tty # Delete any augmented output.
echo " failed" >>/dev/tty
echo ">> Type 'c' to continue, 'd' to see diagnostics, 'u' to update baseline, and 'a' to abort." >/dev/tty
read -r -s -n 1 key </dev/tty
case $key in
[uU])
echo ">> Updating baseline ..." >/dev/tty
exit 0
;;
[cC])
echo ">> Continuing ..." >/dev/tty
exit 1
;;
[aA])
echo ">> Aborting ..." >/dev/tty
exit 200
;;
[dD])
if [ "$TEST_DIAGNOSTICS" != "" ] && [ "$TEST_DIAGNOSTICS" != "/dev/stdout" ]; then
less -S "$TEST_DIAGNOSTICS" </dev/tty >/dev/tty
else
echo "Do not have diagnostics." >/dev/tty
fi
;;
*) echo ">> Answer not recognized, try again ..." >/dev/tty ;;
esac
done