xref: /freebsd/contrib/bsddialog/examples_utility/timebox.sh (revision 7fdf597e96a02165cfe22ff357b857d5fa15ed8a)
1#!/bin/sh
2#-
3# SPDX-License-Identifier: CC0-1.0
4#
5# Written in 2021 by Alfonso Sabato Siciliano.
6#
7# To the extent possible under law, the author has dedicated all copyright
8# and related and neighboring rights to this software to the public domain
9# worldwide. This software is distributed without any warranty, see:
10#	<http://creativecommons.org/publicdomain/zero/1.0/>.
11
12: ${BSDDIALOG_ERROR=255}
13: ${BSDDIALOG_OK=0}
14: ${BSDDIALOG_CANCEL=1}
15: ${BSDDIALOG_ESC=5}
16
17TIME=$(./bsddialog --title " timebox " --timebox "Hello World!" 8 25 \
183>&1 1>&2 2>&3 3>&-)
19
20case $? in
21	$BSDDIALOG_ERROR )
22		exit 1
23	;;
24	$BSDDIALOG_ESC )
25		echo "[ESC]"
26	;;
27	$BSDDIALOG_CANCEL )
28		echo "[Cancel]"
29	;;
30	$BSDDIALOG_OK )
31		echo "[OK] $TIME"
32	;;
33esac
34