-
Notifications
You must be signed in to change notification settings - Fork 2
/
xt5250.in
executable file
·113 lines (105 loc) · 2.72 KB
/
xt5250.in
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#!/bin/sh
# vi:set sts=2 sw=2 autoindent:
#
# xt5250 - Run tn5250 in an xterm, and set up the X resources to make it
# as painless as possible.
#
# These variables are set at ./configure time.
prefix="@prefix@"
exec_prefix="@exec_prefix@"
bindir="@bindir@"
datadir="@datadir@"
pkgdatadir="$datadir/tn5250"
if [ -z "$DIALOG" ] ; then DIALOG="@DIALOG@" ; fi
#
# Figure out if we've got a host name to connect to, if not, and if we
# can find a copy of `dialog', use it to prompt for the host name.
#
get_host () {
XT5250_HOST=""
while [ $# -ne 0 ] ; do
case "$1" in
--help)
exec "$bindir/tn5250";;
-version)
exec "$bindir/tn5250" -version;;
-*|+*|*=*)
;;
*)
if [ -z "$XT5250_HOST" ] ; then XT5250_HOST="$1" ; fi
;;
esac
shift
done
}
if [ "$1" = "-BOOT" ] ; then
shift
#
# If the host wasn't provided, prompt for it.
#
if [ -z "$XT5250_HOST" ] ; then
if [ "$DIALOG" != "no" ] ; then
#
# we have dialog, but does it support backtitle?
#
$DIALOG --help 2>&1 | grep -q backtitle && bt_arg="--backtitle xt5250"
#
# We have a copy of `dialog', so use it.
#
if [ -f "$pkgdatadir/dialogrc" ] ; then
DIALOGRC="$pkgdatadir/dialogrc"
export DIALOGRC
fi
while [ -z "$XT5250_HOST" ] ; do
exec 3>&1
XT5250_HOST="`$DIALOG $bt_arg --title "Connect to Host" \
--inputbox "Enter the name or IP address of the host to connect to:" \
7 60 2>&1 1>&3`"
ret=$?
exec 3>&-
if [ $ret -ne 0 ] ; then exit 1 ; fi
#
# Set the window title (if we can)
#
# Only GNU echo supports -e/-n flags, so use printf if available. If
# neither works, we just silently fail without setting the window title.
#
if command -v printf >/dev/null 2>&1 ; then
printf '\033]0;xt5250 - '"$XT5250_HOST"'\07'
else
echo -e '\033]0;xt5250 - '"$XT5250_HOST"'\07'
fi
done
else
#
# We don't have a copy of `dialog', so we must use the
# shell's `read' function. Oh, well.
#
while [ -z "$XT5250_HOST" ] ; do
echo "Enter name of host to connect to (Ctrl+C to cancel):"
read XT5250_HOST
done
fi
else
XT5250_HOST=""
fi
if [ -z "$XT5250_HOST" ] ; then
exec "$bindir/tn5250" "$@"
else
exec "$bindir/tn5250" "$@" "$XT5250_HOST"
fi
# If the exec fails:
echo "${0##*/}: Can't exec $bindir/tn5250." >&2
exit 1
fi
#
# Start the xterm, and run us again so we can setup inside the xterm.
#
get_host "$@"
XUSERFILESEARCHPATH="$pkgdatadir/%N"
export XUSERFILESEARCHPATH XT5250_HOST
exec xterm -name "xt5250" -bg black -fg white -T "xt5250 - $XT5250_HOST" \
+sb -tn xterm-5250 -geometry 80x25 -e "$0" -BOOT "$@"
# If the exec fails:
echo "${0##*/}: Can't exec xterm." >&2
exit 1