Hello, I would like your comments about the attached patch. This is for making $OPTIONS work on line-oriented terminals. To see the difference, you can try the following after applying the patch:
% cd /usr/ports/print/ghostscript8 && env TERM=foo make config The current implementation of $OPTIONS uses dialog(1) for listing the options, but dialog(1) requires a screen-oriented terminal. Although today's most of terminals used are virtual ones with the capability, there are still a few situations that line-oriented operation is useful; operations over low-speed serial console, for example. Also, another problem of the current implementation is that it silently skips the selection menu if the $TERM is invalid and prevents the selection itself. -- | Hiroki SATO
Index: Mk/bsd.commands.mk
===================================================================
RCS file: /home/ncvs/ports/Mk/bsd.commands.mk,v
retrieving revision 1.3
diff -d -u -I\$FreeBSD:.*\$ -I\$NetBSD:.*\$ -I\$OpenBSD:.*\$ -I\$DragonFly:.*\$
-I\$Id:.*\$ -I\$Translation:.*\$ -I\$hrs:.*\$ -r1.3 bsd.commands.mk
--- Mk/bsd.commands.mk 14 Apr 2008 16:46:41 -0000 1.3
+++ Mk/bsd.commands.mk 7 Dec 2008 18:13:35 -0000
@@ -33,7 +33,7 @@
CPIO?= /usr/bin/cpio
CUT?= /usr/bin/cut
DC?= /usr/bin/dc
-DIALOG?= /usr/bin/dialog
+DIALOG?= ${PORTSDIR}/Tools/scripts/dialog.sh
DIFF?= /usr/bin/diff
DIRNAME?= /usr/bin/dirname
EGREP?= /usr/bin/egrep
Index: Tools/scripts/dialog.sh
===================================================================
RCS file: Tools/scripts/dialog.sh
diff -N Tools/scripts/dialog.sh
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ Tools/scripts/dialog.sh 7 Dec 2008 18:17:00 -0000
@@ -0,0 +1,222 @@
+#!/bin/sh
+#
+# $FreeBSD$
+#
+# Copyright 2003, 2004, 2005, 2006, 2007, 2008 Hiroki Sato <[EMAIL
PROTECTED]>,
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+DIALOG_CMD=/usr/bin/dialog
+
+if ${DIALOG_CMD} --clear 2> /dev/null; then
+ exec ${DIALOG_CMD} "$@"
+fi
+
+shjot()
+{
+ _sj_num=$1
+ _sj_begin=$2
+
+ case ${_sj_num}:${_sj_begin} in
+ [0-9]*:[0-9]*)
+ _sj_i=${_sj_begin}
+ _sj_num=$(( ${_sj_num} + ${_sj_begin} ))
+ ;;
+ *)
+ _sj_i=1
+ ;;
+ esac
+
+ while [ ${_sj_i} -le ${_sj_num} ]; do
+ echo ${_sj_i}
+ _sj_i=$(( ${_sj_i} + 1 ))
+ done
+}
+
+print_sep()
+{
+ echo "---- $*"
+}
+
+calc_b_e()
+{
+ _cbe_begin=$((${IPAGE} * ${CPAGE} + 1))
+ case ${CPAGE} in
+ ${NPAGE}) _cbe_ritems=$(((${NITEMS} - ${IPAGE} * ${CPAGE}) %
${IPAGE})) ;;
+ *) _cbe_ritems=${IPAGE} ;;
+ esac
+ _cbe_end=$((${_cbe_begin} + ${_cbe_ritems} - 1))
+
+ echo ${_cbe_begin} ${_cbe_end} ${_cbe_ritems}
+}
+
+print_knobs()
+{
+ set -- `calc_b_e`
+ _pk_begin=$1
+ _pk_end=$2
+ _pk_ritems=$3
+
+ for _i in `shjot $(( ${_pk_ritems} - 1 )) ${_pk_begin}`; do
+ printf "%3d) [%3s] %s\n" ${_i} "`eval echo \\$PSW_${_i}`"
"`eval echo \\$PITEM_${_i}`"
+ done
+}
+
+print_prompt()
+{
+ print_sep
+
+ set -- `calc_b_e`
+ _begin=$1
+ _end=$2
+ _ritems=$3
+
+ case "${_begin}:${_ritems}:${CPAGE}" in
+ 1:1:*) echo -n "${_begin},le,ld,?,q) " ;;
+ 1:*:${NPAGE}) echo -n "${_begin}-${_end},le,ld,?,q) " ;;
+ *:1:*) echo -n "${_begin},p,le,ld,?,q) ";
+ VALIDC="p" ;;
+ *:*:${NPAGE}) echo -n "${_begin}-${_end},p,le,ld,?,q) ";
+ VALIDC="p" ;;
+ 1:*:*) echo -n "${_begin}-${_end}(max:${NITEMS}),n,le,ld,?,q)
";
+ VALIDC="n" ;;
+ *) echo -n
"${_begin}-${_end}(max:${NITEMS}),p,n,le,ld,?,q) ";
+ VALIDC="pn" ;;
+ esac
+}
+
+print_vars()
+{
+ for _i in `shjot ${NITEMS}`; do
+ case $1:`eval echo \\$PSW_${_i}` in
+ enables:on) echo "WITH_`eval echo \\$PTAG_\${_i}`=true" ;;
+ disables:off) echo "WITHOUT_`eval echo \\$PTAG_\${_i}`=true"
;;
+ knobs:on) echo -n " \"`eval echo \\$PTAG_\${_i}`\"" ;;
+ esac
+ done
+}
+
+flipflop()
+{
+ _tmp=`eval echo \\$PSW_$1`
+
+ case "${_tmp}" in
+ on) echo "off" ;;
+ off) echo "on" ;;
+ *) echo "${_tmp}" ;;
+ esac
+}
+
+check_input()
+{
+ read _in
+
+ case "${_in}:${VALIDC}" in
+
[123456789]:*|[123456789][0123456789]:*|[123456789][0123456789][0123456789]:*)
+ STATE=MENU
+ echo "PSW_${_in}=`flipflop ${_in}`; STATE=${STATE}"
+ ;;
+ q:*|Q:*)
+ echo "STATE=DONE"
+ ;;
+ n:*n*|N:*n*)
+ STATE=MENU
+ echo "PAGE=$((${CPAGE}+1)); STATE=${STATE}"
+ ;;
+ p:*p*|P:*p*)
+ STATE=MENU
+ echo "PAGE=$((${CPAGE}-1)); STATE=${STATE}"
+ ;;
+ ld:*)
+ STATE=NOMENU
+ echo "print_vars disables; STATE=${STATE}"
+ ;;
+ le:*)
+ STATE=NOMENU
+ echo "print_vars enables; STATE=${STATE}"
+ ;;
+ \?:*)
+ STATE=NOMENU
+ MSG=' p: previous\n n: next\n le: list enables\n ld: list
disables\n ?: help\n q: quit\n'
+ echo "print_sep Usage; printf \"${MSG}\"; STATE=${STATE}"
+ ;;
+ *)
+ STATE=NOMENU
+ echo "echo \"invalid command: ${_in}\"; STATE=${STATE}"
+ ;;
+ esac
+}
+
+DONE=0
+CPAGE=0 # current page
+NITEMS=0 # total number of items
+NPAGE=0 # total number of pages
+IPAGE=10 # items per page
+
+while [ $# != 0 ]; do
+ case $1 in
+ --checklist)
+ shift; TITLE=$1
+ shift; WIDTH=$1
+ shift; HEIGHT=$1
+ shift; LHEIGHT=$1
+ shift;
+
+ NITEMS=$(($# / 3))
+ NPAGE=$(($# / 3 / ${IPAGE}))
+
+ for i in `shjot ${NITEMS}`; do
+ eval "PTAG_${i}=\"$1\""
+ eval "PITEM_${i}=\"$2\""
+ eval "PSW_${i}=\"$3\""
+ shift 3
+ done
+
+ break
+ ;;
+ *)
+ shift
+ ;;
+ esac
+done
+
+STATE=MENU;
+
+while :; do
+ case ${STATE} in
+ MENU)
+ print_sep "${TITLE}"
+ print_knobs "${NITEMS}" "${CPAGE}" "${IPAGE}"
+ ;;
+ NOMENU)
+ # do nothing
+ ;;
+ DONE)
+ break;
+ ;;
+ esac
+ print_prompt
+ eval `check_input "${NITEMS}" "${CPAGE}" "${IPAGE}"`
+done
+
+print_vars knobs >&2
pgp9U4dgmG70L.pgp
Description: PGP signature
