xref: /freebsd/contrib/bsddialog/examples_utility/menu.sh (revision 61ba55bcf70f2340f9c943c9571113b3fd8eda69)
1f499134dSBaptiste Daroussin#!/bin/sh
2f499134dSBaptiste Daroussin#-
3f499134dSBaptiste Daroussin# SPDX-License-Identifier: CC0-1.0
4f499134dSBaptiste Daroussin#
5f499134dSBaptiste Daroussin# Written in 2021 by Alfonso Sabato Siciliano.
6bce40c02SAlfonso S. Siciliano#
7f499134dSBaptiste Daroussin# To the extent possible under law, the author has dedicated all copyright
8f499134dSBaptiste Daroussin# and related and neighboring rights to this software to the public domain
9f499134dSBaptiste Daroussin# worldwide. This software is distributed without any warranty, see:
10f499134dSBaptiste Daroussin#	<http://creativecommons.org/publicdomain/zero/1.0/>.
11f499134dSBaptiste Daroussin
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
17bce40c02SAlfonso S. SicilianoITEM=$(./bsddialog --title " menu " --menu "Hello World!" 15 30 5 \
18*61ba55bcSBaptiste Daroussin	"1 Name"  "DESC  1  xyz" \
19*61ba55bcSBaptiste Daroussin	"2 Name"  "DESC  2  xyz" \
20*61ba55bcSBaptiste Daroussin	"3 Name"  "DESC  3  xyz" \
21*61ba55bcSBaptiste Daroussin	"4 Name"  "DESC  4  xyz" \
22*61ba55bcSBaptiste Daroussin	"5 Name"  "DESC  5  xyz" \
23bce40c02SAlfonso S. Siciliano3>&1 1>&2 2>&3 3>&-)
24bce40c02SAlfonso S. Siciliano
25bce40c02SAlfonso S. Sicilianocase $? in
26bce40c02SAlfonso S. Siciliano	$BSDDIALOG_ERROR )
27bce40c02SAlfonso S. Siciliano		exit 1
28bce40c02SAlfonso S. Siciliano	;;
29bce40c02SAlfonso S. Siciliano	$BSDDIALOG_ESC )
30*61ba55bcSBaptiste Daroussin		echo "[ESC]"
31bce40c02SAlfonso S. Siciliano	;;
32bce40c02SAlfonso S. Siciliano	$BSDDIALOG_CANCEL )
33*61ba55bcSBaptiste Daroussin		echo "[Cancel]"
34bce40c02SAlfonso S. Siciliano	;;
35bce40c02SAlfonso S. Siciliano	$BSDDIALOG_OK )
36bce40c02SAlfonso S. Siciliano		echo "[OK] $ITEM"
37bce40c02SAlfonso S. Siciliano	;;
38bce40c02SAlfonso S. Sicilianoesac
39