Date: Mon, 26 Mar 2018 17:25:31 -0700 From: Devin Teske <dteske@freebsd.org> To: Kyle Evans <kevans@FreeBSD.org> Cc: Devin Teske <dteske@freebsd.org>, src-committers <src-committers@freebsd.org>, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r331563 - head/stand/lua Message-ID: <9CF74768-8B7D-4F29-AAD1-A2802665635E@freebsd.org> In-Reply-To: <201803261901.w2QJ1MUj074381@repo.freebsd.org> References: <201803261901.w2QJ1MUj074381@repo.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
Woot! That is all. --=20 Devin > On Mar 26, 2018, at 12:01 PM, Kyle Evans <kevans@FreeBSD.org> wrote: >=20 > Author: kevans > Date: Mon Mar 26 19:01:22 2018 > New Revision: 331563 > URL: https://svnweb.freebsd.org/changeset/base/331563 >=20 > Log: > lualoader: Implement try_include and use it for including the local = module >=20 > This provides a way to optionally include a module without having to = wrap it > in filesystem checks. try_include is a little more robust, using the = lua > search path instead of forcing us to explicitly consider all of the = places > we could want to include a module. Errors are still generally raised = from > trying to load the module, but ENOENT will not get raised unless = we're doing > a verbose load. >=20 > This will also be used to split out logo/brand graphics into their = own files > so that we can safely scale up the number of graphics included = without > worrying about the extra memory consumption- opting to lazily load = graphics > instead. >=20 > Reviewed by: cem > Differential Revision: https://reviews.freebsd.org/D14658 >=20 > Modified: > head/stand/lua/core.lua > head/stand/lua/loader.lua >=20 > Modified: head/stand/lua/core.lua > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D > --- head/stand/lua/core.lua Mon Mar 26 18:39:38 2018 = (r331562) > +++ head/stand/lua/core.lua Mon Mar 26 19:01:22 2018 = (r331563) > @@ -41,6 +41,26 @@ local function composeLoaderCmd(cmd_name, argstr) > return cmd_name > end >=20 > +-- Globals > +-- try_include will return the loaded module on success, or nil on = failure. > +-- A message will also be printed on failure, with one exception: = non-verbose > +-- loading will suppress 'module not found' errors. > +function try_include(module) > + local status, ret =3D pcall(require, module) > + -- ret is the module if we succeeded. > + if status then > + return ret > + end > + -- Otherwise, ret is just a message; filter out ENOENT unless = we're > + -- doing a verbose load. As a consequence, try_include prior to = loading > + -- configuration will not display 'module not found'. All other = errors > + -- in loading will be printed. > + if config.verbose or ret:match("^module .+ not found") =3D=3D = nil then > + print(ret) > + end > + return nil > +end > + > -- Module exports > -- Commonly appearing constants > core.KEY_BACKSPACE =3D 8 >=20 > Modified: head/stand/lua/loader.lua > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D > --- head/stand/lua/loader.lua Mon Mar 26 18:39:38 2018 = (r331562) > +++ head/stand/lua/loader.lua Mon Mar 26 19:01:22 2018 = (r331563) > @@ -43,11 +43,7 @@ if not core.isMenuSkipped() then > end > local password =3D require("password") >=20 > -local result =3D lfs.attributes("/boot/lua/local.lua") > --- Effectively discard any errors; we'll just act if it succeeds. > -if result ~=3D nil then > - require("local") > -end > +try_include("local") >=20 > config.load() > if core.isUEFIBoot() then >=20
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?9CF74768-8B7D-4F29-AAD1-A2802665635E>