xref: /titanic_44/usr/src/grub/grub-0.97/util/grub-terminfo.in (revision 49b225e1cfa7bbf7738d4df0a03f18e3283426eb)
1#! /bin/sh
2# Generate a terminfo command from a terminfo name.
3#
4# Copyright (C) 2002  Free Software Foundation, Inc.
5#
6# This file is free software; you can redistribute it and/or modify it
7# under the terms of the GNU General Public License as published by
8# the Free Software Foundation; either version 2 of the License, or
9# (at your option) any later version.
10#
11# This program is distributed in the hope that it will be useful, but
12# WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14# General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with this program; if not, write to the Free Software
18# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19
20VERSION=@VERSION@
21
22usage () {
23    cat <<EOF
24Usage: grub-terminfo TERMNAME
25Generate a terminfo command from a terminfo name.
26
27  -h, --help              print this message and exit
28  -v, --version           print the version information and exit
29
30Report bugs to <bug-grub@gnu.org>.
31EOF
32}
33
34error () {
35    echo "grub-terminfo: error: $1" 1>&2
36}
37
38termname=
39
40for option in "$@"; do
41    case "$option" in
42    -h | --help)
43        usage
44	exit 0 ;;
45    -v | --version)
46	echo "grub-terminfo (GNU GRUB ${VERSION})"
47	exit 0 ;;
48    -*)
49	error "Unrecognized option \`$option'"
50	usage
51	exit 1 ;;
52    *)
53	if test "x$termname" != x; then
54	    error "More than one terminfo names?"
55	    usage
56	    exit 1
57	fi
58	termname="$option" ;;
59    esac
60done
61
62if test "x$termname" = x; then
63    error "termname not specified"
64    usage
65    exit 1
66fi
67
68get_seq () {
69    infocmp -L -1 -g $termname | sed -n -e "/$1/s/^[^=]*=\\(.*\\),\$/\\1/p"
70}
71
72cursor_address="`get_seq cursor_address`"
73if test "x$cursor_address" = x; then
74    error "cursor_address not found"
75    exit 1
76fi
77cursor_address="--cursor-address=$cursor_address"
78
79clear_screen="`get_seq clear_screen`"
80if test "x$clear_screen" != x; then
81    clear_screen="--clear-screen=$clear_screen"
82fi
83
84enter_standout_mode="`get_seq enter_standout_mode`"
85if test "x$enter_standout_mode" != x; then
86    enter_standout_mode="--enter-standout-mode=$enter_standout_mode"
87fi
88
89exit_standout_mode="`get_seq exit_standout_mode`"
90if test "x$exit_standout_mode" != x; then
91    exit_standout_mode="--exit-standout-mode=$exit_standout_mode"
92fi
93
94echo "terminfo --name=$termname" $cursor_address $clear_screen \
95    $enter_standout_mode $exit_standout_mode
96