[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

cdebconf feature?



If the user wants to go through the network configuration a second time (they
mistyped something) , I'd like to have the default set to their previous
answer, and I'd like it to be obvious that the defaults are such.  

I can't figure out how to get this behavior with the current version of
cdebconf.

One idea is to do variable substitutions in the 'Default' field, but that is
dangerous because defaults are generally thought of as safe, and something the
user entered is not necessarily correct or safe. cdebconf doesn't currently
substitute in that field, probably for that very reason.

The other option, (which I think makes sense?) you can see in the attached diff.
I modified the 'string' input handler for the text frontend to get the behavior
I am looking for. 

Here's an incomplete diff (it only changed the 'string' handler for the text
frontend) that shows what I'm looking for.  If the question has a default
specified in the template, the behavior does not change.  If the question
doesn't currently have an answer in the database, the behavior does not change.
Otherwise, the user is shown the current value in the database as the default.

Comments, questions, better ways, welcome,

David


Index: modules/frontend/text/text.c
===================================================================
RCS file: /cvs/debian-boot/debian-installer/tools/cdebconf/src/modules/frontend/text/text.c,v
retrieving revision 1.4
diff -u -r1.4 text.c
--- modules/frontend/text/text.c	2000/12/12 05:13:36	1.4
+++ modules/frontend/text/text.c	2000/12/17 00:06:34
@@ -219,15 +219,19 @@
 static int texthandler_string(struct frontend *obj, struct question *q)
 {
 	char buf[1024] = {0};
-	if (q->template->defaultval)
-		printf("[%s]", q->template->defaultval);
+ 	if (q->template->defaultval)
+	    printf("[%s]", q->template->defaultval);
+	else if (q->value)
+	    printf("[%s]", q->value);
+
 	printf("> "); fflush(stdout);
 	fgets(buf, sizeof(buf), stdin);
 	CHOMP(buf);
 	if (buf[0] == 0 && q->template->defaultval != 0)
 		question_setvalue(q, q->template->defaultval);
-	else
-		question_setvalue(q, buf);
+	else if (buf[0]!=0)
+	    question_setvalue(q, buf);
+	
 	return DC_OK;
 }
 



Reply to: