git: e44751530e04 - main - bsdinstall hostname: Restore bsdconfig API

From: Alfonso S. Siciliano <asiciliano_at_FreeBSD.org>
Date: Thu, 19 Oct 2023 11:00:19 UTC
The branch main has been updated by asiciliano:

URL: https://cgit.FreeBSD.org/src/commit/?id=e44751530e04ef8326ff22c0d3f7d880c82d3395

commit e44751530e04ef8326ff22c0d3f7d880c82d3395
Author:     Alfonso S. Siciliano <asiciliano@FreeBSD.org>
AuthorDate: 2023-10-19 10:54:24 +0000
Commit:     Alfonso S. Siciliano <asiciliano@FreeBSD.org>
CommitDate: 2023-10-19 10:59:49 +0000

    bsdinstall hostname: Restore bsdconfig API
    
    Restore bsdconfig API to handle hostname dialog because bsddialog 1.0
    matches all features required by bsdconfig(1). Implicitly this commit
    restores also Xdialog(1) for this script.
    
    This commit reverts:
     - "bsdinstall hostname: Replace dialog with bsddialog"
       6368dcb29228dd8e18d50c54c3ca1596262d4676
     - "bsdinstall(8) hostname: Update for bsddialog 0.3"
       5f3ec44e7e9c11f90ad1128db1116925b493fad0.
    
    The script continues to use bsddialog(1) by default via $DIALOG in
    bsdconfig(1).
---
 usr.sbin/bsdinstall/scripts/hostname | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/usr.sbin/bsdinstall/scripts/hostname b/usr.sbin/bsdinstall/scripts/hostname
index 7aa97ef095f7..19df8885893b 100755
--- a/usr.sbin/bsdinstall/scripts/hostname
+++ b/usr.sbin/bsdinstall/scripts/hostname
@@ -47,8 +47,6 @@ f_include $BSDCFG_SHARE/dialog.subr
 
 ############################################################ GLOBALS
 
-: ${BSDDIALOG_CANCEL=1}
-
 #
 # Strings that should be moved to an i18n file and loaded with f_include_lang()
 #
@@ -75,14 +73,18 @@ dialog_hostname()
 	local hline=
 	local value="$*"
 
-	bsddialog \
+	local height width
+	f_dialog_inputbox_size height width \
+		"$DIALOG_TITLE" "$DIALOG_BACKTITLE" "$prompt" "$value" "$hline"
+
+	$DIALOG \
 		--title "$DIALOG_TITLE"         \
 		--backtitle "$DIALOG_BACKTITLE" \
 		--hline "$hline"                \
 		--ok-label "$msg_ok"            \
 		--no-cancel                     \
 		--inputbox "$prompt"            \
-		0 0 "$value"                    \
+		$height $width "$value"         \
 		2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
 }
 
@@ -98,7 +100,7 @@ f_dialog_backtitle "$msg_freebsd_installer"
 # Get user input
 #
 HOSTNAME=$( dialog_hostname "$HOSTNAME" )
-[ $? -eq $BSDDIALOG_CANCEL ] && exit 1
+[ $? -eq $DIALOG_CANCEL ] && exit 1
 
 #
 # Store the user's choice