Date: Tue, 25 Mar 2014 03:30:44 +0000 (UTC) From: Devin Teske <dteske@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r263705 - in stable/9/sys/boot: forth i386/loader Message-ID: <201403250330.s2P3Uicl057386@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: dteske Date: Tue Mar 25 03:30:44 2014 New Revision: 263705 URL: http://svnweb.freebsd.org/changeset/base/263705 Log: MFC r258270: 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 Modified: stable/9/sys/boot/forth/loader.4th stable/9/sys/boot/forth/loader.4th.8 stable/9/sys/boot/forth/loader.rc stable/9/sys/boot/forth/menu.rc stable/9/sys/boot/i386/loader/loader.rc Directory Properties: stable/9/ (props changed) stable/9/sys/ (props changed) stable/9/sys/boot/ (props changed) stable/9/sys/boot/forth/ (props changed) Modified: stable/9/sys/boot/forth/loader.4th ============================================================================== --- stable/9/sys/boot/forth/loader.4th Tue Mar 25 03:28:58 2014 (r263704) +++ stable/9/sys/boot/forth/loader.4th Tue Mar 25 03:30:44 2014 (r263705) @@ -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 Modified: stable/9/sys/boot/forth/loader.4th.8 ============================================================================== --- stable/9/sys/boot/forth/loader.4th.8 Tue Mar 25 03:28:58 2014 (r263704) +++ stable/9/sys/boot/forth/loader.4th.8 Tue Mar 25 03:30:44 2014 (r263705) @@ -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 modu 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 Modified: stable/9/sys/boot/forth/loader.rc ============================================================================== --- stable/9/sys/boot/forth/loader.rc Tue Mar 25 03:28:58 2014 (r263704) +++ stable/9/sys/boot/forth/loader.rc Tue Mar 25 03:30:44 2014 (r263705) @@ -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 Modified: stable/9/sys/boot/forth/menu.rc ============================================================================== --- stable/9/sys/boot/forth/menu.rc Tue Mar 25 03:28:58 2014 (r263704) +++ stable/9/sys/boot/forth/menu.rc Tue Mar 25 03:30:44 2014 (r263705) @@ -120,6 +120,10 @@ set optionstoggled_ansi[6]="[1mV[37mer \ 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 Modified: stable/9/sys/boot/i386/loader/loader.rc ============================================================================== --- stable/9/sys/boot/i386/loader/loader.rc Tue Mar 25 03:28:58 2014 (r263704) +++ stable/9/sys/boot/i386/loader/loader.rc Tue Mar 25 03:30:44 2014 (r263705) @@ -3,6 +3,7 @@ \ \ Includes additional commands include /boot/loader.4th +try-include /boot/loader.rc.local \ Reads and processes loader.conf variables initialize
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201403250330.s2P3Uicl057386>