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