aboutsummaryrefslogtreecommitdiff
path: root/sys/boot
diff options
context:
space:
mode:
authorDevin Teske <dteske@FreeBSD.org>2013-11-17 18:12:17 +0000
committerDevin Teske <dteske@FreeBSD.org>2013-11-17 18:12:17 +0000
commitf697065fda776c569924b3453467ca4913280198 (patch)
tree985f6bb0b806a59afb9ef41dc73d439b0c30b19d /sys/boot
parentc0264af94b7c434658c6248af89977efc6317935 (diff)
downloadsrc-f697065fda776c569924b3453467ca4913280198.tar.gz
src-f697065fda776c569924b3453467ca4913280198.zip
Add a try-include word (which acts the same as "include") and use it to
conditionally include (but ignore failures) /boot/loader.rc.local and /boot/menu.rc.local -- to make customizing the menu easier. Reviewed by: alfred Discussed on: -hackers
Notes
Notes: svn path=/head/; revision=258270
Diffstat (limited to 'sys/boot')
-rw-r--r--sys/boot/forth/loader.4th9
-rw-r--r--sys/boot/forth/loader.4th.89
-rw-r--r--sys/boot/forth/loader.rc1
-rw-r--r--sys/boot/forth/menu.rc4
-rw-r--r--sys/boot/i386/loader/loader.rc1
5 files changed, 23 insertions, 1 deletions
diff --git a/sys/boot/forth/loader.4th b/sys/boot/forth/loader.4th
index 22d9125a3a33..55778ff4b377 100644
--- a/sys/boot/forth/loader.4th
+++ b/sys/boot/forth/loader.4th
@@ -233,7 +233,16 @@ include /boot/check-password.4th
s" disable-module" s" disable loading of a module" .?
s" toggle-module" s" toggle loading of a module" .?
s" show-module" s" show module load data" .?
+ s" try-include" s" try to load/interpret files" .?
;
+: try-include ( -- ) \ see loader.4th(8)
+ ['] include ( -- xt ) \ get the execution token of `include'
+ catch ( xt -- exception# | 0 ) if \ failed
+ LF parse ( c -- s-addr/u ) 2drop \ advance >in to EOL (drop data)
+ \ ... prevents words unused by `include' from being interpreted
+ then
+; immediate \ interpret immediately for access to `source' (aka tib)
+
only forth also
diff --git a/sys/boot/forth/loader.4th.8 b/sys/boot/forth/loader.4th.8
index 02f96410b6d9..b689077058da 100644
--- a/sys/boot/forth/loader.4th.8
+++ b/sys/boot/forth/loader.4th.8
@@ -24,7 +24,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd October 17, 2013
+.Dd November 13, 2013
.Dt LOADER.4TH 8
.Os
.Sh NAME
@@ -158,6 +158,13 @@ files to specify the action after a module loading fails.
Used inside
.Xr loader.conf 5
files to specify the action after a module loading fails.
+.It Ic try-include Ar file Op Ar
+Process script files if they exist.
+Each file, in turn, is completely read into memory,
+and then each of its lines is passed to the command line interpreter.
+If any error is returned by the interpreter, the try-include
+command aborts immediately, without reading any other files, and
+silently returns without error.
.El
.Sh FILES
.Bl -tag -width /boot/loader.4th -compact
diff --git a/sys/boot/forth/loader.rc b/sys/boot/forth/loader.rc
index a84753da0263..b4a6d51c4c4a 100644
--- a/sys/boot/forth/loader.rc
+++ b/sys/boot/forth/loader.rc
@@ -3,6 +3,7 @@
\
\ Includes additional commands
include /boot/loader.4th
+try-include /boot/loader.rc.local
\ Reads and processes loader.conf variables
\ NOTE: Change to `initialize' if you enable the below boot menu
diff --git a/sys/boot/forth/menu.rc b/sys/boot/forth/menu.rc
index 3d8bff97e80b..e49f5676f54a 100644
--- a/sys/boot/forth/menu.rc
+++ b/sys/boot/forth/menu.rc
@@ -120,6 +120,10 @@ set optionstoggled_ansi[6]="Verbose..... On"
\
set menu_timeout_command="boot"
+\ Include optional elements defined in a local file
+\
+try-include /boot/menu.rc.local
+
\ Display the main menu (see `menu.4th')
set menuset_initial=1
menuset-loadinitial
diff --git a/sys/boot/i386/loader/loader.rc b/sys/boot/i386/loader/loader.rc
index cb2f723f2495..287c05efdfed 100644
--- a/sys/boot/i386/loader/loader.rc
+++ b/sys/boot/i386/loader/loader.rc
@@ -3,6 +3,7 @@
\
\ Includes additional commands
include /boot/loader.4th
+try-include /boot/loader.rc.local
\ Reads and processes loader.conf variables
initialize