Index | Thread | Search

From:
obsd@mulh.net
Subject:
Re: Allow autoinstall response file to select default answer
To:
tech@openbsd.org
Date:
Mon, 5 Oct 2026 04:20:58 -0400

Download raw body.

Thread
  • obsd@mulh.net:

    Allow autoinstall response file to select default answer

On 2026-10-05 6:15:27, Klemens Nanni wrote:
> How does this behave for questions without default where non-empty
> values are required?

It will do the same as if the question is not in the response file
which is run  err_exit "Question has no answer in response file:"

The while loop "return"s if it finds a response.
If the while loop finishes without finding a match then
the _autorespond() function continues to its' last two lines
and these lines return the default answer or err_exit.

My change, when a match is found and the =value is blank
just "break"s from the while loop instead of returning
an empty string, thus letting those last two lines
handle the case of a default response.

    while ....
    done ....
    [[ -n $_def ]] && resp=$_def && return
    err_exit "\nQuestion has no answer in response file: \"$_q\""

>>RCS file: /cvs/src/distrib/miniroot/install.sub,v
>>diff -u -p -u -r1.1292 install.sub
>>--- install.sub	19 Sep 2026 19:52:10 -0000	1.1292
>>+++ install.sub	4 Oct 2026 22:55:49 -0000
>>@@ -740,11 +740,16 @@ _autorespond() {
>> 
>> 	mv /tmp/ai/ai.conf /tmp/ai/ai.conf.tmp
>> 	while IFS=' 	' read -r _l; do
>>-		[[ $_l == [!#=]*=?* ]] || continue
>>+		[[ $_l == [!#=]*=* ]] || continue
>> 		_key=${_l%%*([[:blank:]])=*}
>> 		_val=${_l##*([!=])=*([[:blank:]])}
>> 		[[ $_q == @(|*[[:blank:]])"$_key"@([[:blank:]?]*|) ]] &&
>>-			resp=$_val && cat && return
>>+			resp=$_val && cat &&
>>+				if [[ -n $resp ]] then
>>+					return
>>+				else
>>+					break
>>+				fi
>> 		print -r " $_l"
>> 	done </tmp/ai/ai.conf.tmp >/tmp/ai/ai.conf
>> 	[[ -n $_def ]] && resp=$_def && return