From owner-svn-src-all@FreeBSD.ORG Sat Dec 29 00:01:25 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 6D7CFD3B; Sat, 29 Dec 2012 00:01:25 +0000 (UTC) (envelope-from dteske@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 522DD8FC0C; Sat, 29 Dec 2012 00:01:25 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id qBT01P7n030930; Sat, 29 Dec 2012 00:01:25 GMT (envelope-from dteske@svn.freebsd.org) Received: (from dteske@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id qBT01PV3030929; Sat, 29 Dec 2012 00:01:25 GMT (envelope-from dteske@svn.freebsd.org) Message-Id: <201212290001.qBT01PV3030929@svn.freebsd.org> From: Devin Teske Date: Sat, 29 Dec 2012 00:01:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r244801 - head/usr.sbin/bsdconfig/share X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 29 Dec 2012 00:01:25 -0000 Author: dteske Date: Sat Dec 29 00:01:24 2012 New Revision: 244801 URL: http://svnweb.freebsd.org/changeset/base/244801 Log: Add support for running without a controlling terminal (for example, when running as an rvalue to a pipe). Modified: head/usr.sbin/bsdconfig/share/dialog.subr Modified: head/usr.sbin/bsdconfig/share/dialog.subr ============================================================================== --- head/usr.sbin/bsdconfig/share/dialog.subr Fri Dec 28 23:52:46 2012 (r244800) +++ head/usr.sbin/bsdconfig/share/dialog.subr Sat Dec 29 00:01:24 2012 (r244801) @@ -77,6 +77,11 @@ unset XDIALOG_INFOBOX_TIMEOUT # : ${DIALOG_SELF_INITIALIZE=1} +# +# Default terminal size (used if/when running without a controlling terminal) +# +: ${DEFAULT_TERMINAL_SIZE:=24 80} + ############################################################ GENERIC FUNCTIONS # f_dialog_title [$new_title] @@ -193,7 +198,8 @@ f_dialog_infobox_size() max_size="$XDIALOG_MAXSIZE" # see CONFIGURATION else min_width=24 - max_size=$( stty size ) # usually "24 80" + max_size=$( stty size 2> /dev/null ) # usually "24 80" + : ${max_size:=$DEFAULT_TERMINAL_SIZE} fi local max_height="${max_size%%[$IFS]*}" @@ -325,7 +331,8 @@ f_dialog_buttonbox_size() if [ "$USE_XDIALOG" ]; then max_size="$XDIALOG_MAXSIZE" # see CONFIGURATION else - max_size=$( stty size ) # usually "24 80" + max_size=$( stty size 2> /dev/null ) # usually "24 80" + : ${max_size:=$DEFAULT_TERMINAL_SIZE} fi local max_height="${max_size%%[$IFS]*}" [ $height -le $max_height ] || height=$max_height @@ -363,7 +370,8 @@ f_dialog_inputbox_size() max_size="$XDIALOG_MAXSIZE" # see CONFIGURATION else min_width=24 - max_size=$( stty size ) # usually "24 80" + max_size=$( stty size 2> /dev/null ) # usually "24 80" + : ${max_size:=$DEFAULT_TERMINAL_SIZE} fi local max_height="${max_size%%[$IFS]*}" local max_width="${max_size##*[$IFS]}" @@ -521,7 +529,8 @@ f_dialog_menu_size() else min_width=24 min_rows=0 - max_size=$( stty size ) # usually "24 80" + max_size=$( stty size 2> /dev/null ) # usually "24 80" + : ${max_size:=$DEFAULT_TERMINAL_SIZE} fi local max_width="${max_size##*[$IFS]}" @@ -603,7 +612,8 @@ f_dialog_menu_with_help_size() else min_width=24 min_rows=0 - max_size=$( stty size ) # usually "24 80" + max_size=$( stty size 2> /dev/null ) # usually "24 80" + : ${max_size:=$DEFAULT_TERMINAL_SIZE} fi local max_width="${max_size##*[$IFS]}" @@ -702,7 +712,8 @@ f_dialog_radiolist_size() else min_width=24 min_rows=0 - max_size=$( stty size ) # usually "24 80" + max_size=$( stty size 2> /dev/null ) # usually "24 80" + : ${max_size:=$DEFAULT_TERMINAL_SIZE} fi local max_width="${max_size##*[$IFS]}" @@ -788,7 +799,8 @@ f_dialog_calendar_size() else min_height=0 min_width=40 - max_size=$( stty size ) # usually "24 80" + max_size=$( stty size 2> /dev/null ) # usually "24 80" + : ${max_size:=$DEFAULT_TERMINAL_SIZE} fi local max_height="${max_size%%[$IFS]*}" local max_width="${max_size##*[$IFS]}" @@ -866,7 +878,8 @@ f_dialog_timebox_size() else min_height=0 min_width=20 - max_size=$( stty size ) # usually "24 80" + max_size=$( stty size 2> /dev/null ) # usually "24 80" + : ${max_size:=$DEFAULT_TERMINAL_SIZE} fi local max_height="${max_size%%[$IFS]*}" local max_width="${max_size##*[$IFS]}"