test/countineyn terminal and error code
Juan Batiz-Benet committed
Dec 9, 2014 at 02:20 UTC
a9da519715f003022acb98b9630238bb621aaa78
1 file changed
+5
-2
test/bin/continueyn
+5
-2
@@ -2,9 +2,12 @@
2
# Author: Juan Batiz-Benet <juan@benet.ai>
3
# MIT LICENSED
4
5
+# if not a terminal, exit 0 (yes!)
6
+test -t 1 || exit 0
7
+
8
read -p "continue? [y/N] "
9
echo
7
-if [[ $REPLY =~ ^[Yy]$ ]]; then
10
+if [[ $REPLY =~ ^[Yy] ]]; then
11
exit 0
12
fi
10
-exit -1
13
+exit 1