From owner-svn-src-head@freebsd.org Tue Mar 27 00:25:39 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8D637F56AA3; Tue, 27 Mar 2018 00:25:39 +0000 (UTC) (envelope-from devin@shxd.cx) Received: from shxd.cx (mail.shxd.cx [64.201.244.140]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 2EC1A7F3CB; Tue, 27 Mar 2018 00:25:39 +0000 (UTC) (envelope-from devin@shxd.cx) Received: from [74.217.198.10] (port=59888 helo=[10.1.4.66]) by shxd.cx with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.77 (FreeBSD)) (envelope-from ) id 1f0Z1k-000BEs-AB; Mon, 26 Mar 2018 20:47:36 +0000 Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Subject: Re: svn commit: r331563 - head/stand/lua From: Devin Teske In-Reply-To: <201803261901.w2QJ1MUj074381@repo.freebsd.org> Date: Mon, 26 Mar 2018 17:25:31 -0700 Cc: Devin Teske , src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Transfer-Encoding: quoted-printable Message-Id: <9CF74768-8B7D-4F29-AAD1-A2802665635E@freebsd.org> References: <201803261901.w2QJ1MUj074381@repo.freebsd.org> To: Kyle Evans X-Mailer: Apple Mail (2.3273) Sender: devin@shxd.cx X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Mar 2018 00:25:39 -0000 Woot! That is all. --=20 Devin > On Mar 26, 2018, at 12:01 PM, Kyle Evans 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