xref: /freebsd/contrib/bsddialog/examples_utility/inputbox.sh (revision aa1a8ff2d6dbc51ef058f46f3db5a8bb77967145)
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
17FORM=$(./bsddialog --title " inputbox " --inputbox "Hello World!" 12 40 init \
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] $FORM"
32	;;
33esac
34