If a menu line in boot.cfg has an empty description, then re-use the

command as the description.  For example,

	menu=:boot netbsd -s

now works like

	menu=boot netbsd -s:boot netbsd -s
This commit is contained in:
apb 2008-01-05 19:29:16 +00:00
parent bba8223c2b
commit 4ee202cfe2
2 changed files with 22 additions and 9 deletions

View File

@ -1,4 +1,4 @@
.\" $NetBSD: boot.cfg.5,v 1.3 2007/11/22 15:27:22 sborrill Exp $
.\" $NetBSD: boot.cfg.5,v 1.4 2008/01/05 19:29:16 apb Exp $
.\"
.\" Copyright (c) 2007 Stephen Borrill
.\" All rights reserved.
@ -67,12 +67,16 @@ banner line with no value should be given.
Used to define a menu item to be displayed to the end-user at boot time
which allows a series of boot commands to be run without further typing.
The value consists of the required menu text, followed by a colon
.Po So : Sc Pc
.Pq Sq \&:
and then the desired command.
If the specified menu text is empty
(the colon appears immediately after the equals sign),
then the displayed menu text is the same as the command.
For example:
.Bd -literal
menu=Boot normally:boot
menu=Boot single-user:boot -s
menu=:boot hd1a:netbsd -as
.Ed
.Pp
Each menu item will be prefixed by an ascending number when displayed,

View File

@ -1,4 +1,4 @@
/* $NetBSD: boot2.c,v 1.20 2008/01/02 10:39:39 sborrill Exp $ */
/* $NetBSD: boot2.c,v 1.21 2008/01/05 19:29:16 apb Exp $ */
/*
* Copyright (c) 2003
@ -288,6 +288,7 @@ atoi(const char *in)
* banner=Please choose the boot type from the following menu
* menu=Boot NetBSD:boot netbsd
* menu=Boot into single user mode:boot netbsd -s
* menu=:boot hd1a:netbsd -cs
* menu=Goto boot comand line:prompt
* timeout=10
* consdev=com0
@ -300,7 +301,7 @@ parsebootconf(const char *conf)
int cmenu, cbanner, len;
int fd, err, off;
struct stat st;
char *value, *key;
char *key, *value, *v2;
#ifdef SUPPORT_USTARFS
void *op_open;
#endif
@ -375,15 +376,23 @@ parsebootconf(const char *conf)
*c = 0;
if (!strncmp(key, "menu", 4)) {
/*
* Parse "menu=<description>:<command>". If the
* description is empty ("menu=:<command>)",
* then re-use the command as the description.
* Note that the command may contain embedded
* colons.
*/
if (cmenu >= MAXMENU)
continue;
bootconf.desc[cmenu] = value;
/* Look for : between description and command */
for (; *value && *value != ':'; value++)
for (v2=value; *v2 && *v2 != ':'; v2++)
continue;
if(*value) {
*value++ = 0;
bootconf.command[cmenu] = value;
if (*v2) {
*v2++ = 0;
bootconf.command[cmenu] = v2;
if (! *value)
bootconf.desc[cmenu] = v2;
cmenu++;
} else {
/* No delimiter means invalid line */