Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Wo6gV-00029G-4r for mharc-grub-devel@gnu.org; Sat, 24 May 2014 03:48:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60113) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wo6gL-000270-73 for grub-devel@gnu.org; Sat, 24 May 2014 03:48:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wo6gD-0004cy-N1 for grub-devel@gnu.org; Sat, 24 May 2014 03:47:53 -0400 Received: from mail-oa0-f52.google.com ([209.85.219.52]:39726) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wo6gD-0004cq-IJ for grub-devel@gnu.org; Sat, 24 May 2014 03:47:45 -0400 Received: by mail-oa0-f52.google.com with SMTP id eb12so6465422oac.25 for ; Sat, 24 May 2014 00:47:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-type; bh=HbvPjwtUuzmnX5ZrQfmnSNp08Y5m4rQZdnUD2TMlZI0=; b=IgFgNmMvUFPar+EykJHFxeECF5Kj5Mu1t/k4/B1qQiA0BzPrMhBfrIqUF5bo/wBw6a YDJ2etNyv37G0sf9yDqrkMt3eSUoXlnd1eT/NCJUZ+sVMYqwkZzFOsYOdWpClneijMgJ aDmlOwEfMDGHJ5Jo8Gh58t1vFL05H0Kh05oYHLYikjrlu+IdGmCAB1hchE1Wk+5y3FQh udXXcHpl9Hy26CIOFMfzyYvcFdikiTQ70nNV2zrZfeLbhxSP5IIt0ozkmxlTcxlXRLEG GBvCp8XiLnuPrpXrhkAPlsrVQlAERNdtrAYSV0a82D24gCVlGerBXJEeCng2SN+k8wWG TmKA== X-Gm-Message-State: ALoCoQnoXDvdfLPcCyR4vYxbj5eqtVkxtrPuXYYqBU/xi99xUox2NThIGGb+8CovuE+MjGgpnatM X-Received: by 10.182.76.38 with SMTP id h6mr10534712obw.8.1400917663996; Sat, 24 May 2014 00:47:43 -0700 (PDT) Received: from crass-Ideapad-Z570 (cpe-70-117-77-21.austin.res.rr.com. [70.117.77.21]) by mx.google.com with ESMTPSA id to6sm10009950obb.6.2014.05.24.00.47.42 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sat, 24 May 2014 00:47:43 -0700 (PDT) Date: Sat, 24 May 2014 02:47:34 -0500 From: Glenn Washburn To: The development of GNU GRUB Subject: Re: [PATCH] Allow user-defined functions to override builtins. Message-ID: <20140524024734.1c602c5b@crass-Ideapad-Z570> In-Reply-To: <537DA7CC.8000507@gmail.com> References: <20140519013715.1e36d215@crass-Ideapad-Z570> <537DA7CC.8000507@gmail.com> X-Mailer: Claws Mail 3.9.3 (GTK+ 2.24.20; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; boundary="Sig_/wPeK9BIrX5W4gy231srlyqi"; protocol="application/pgp-signature" X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.219.52 Cc: phcoder@gmail.com X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 24 May 2014 07:48:01 -0000 --Sig_/wPeK9BIrX5W4gy231srlyqi Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Thu, 22 May 2014 09:31:24 +0200 Vladimir '=CF=86-coder/phcoder' Serbinenko wrote: > On 19.05.2014 08:37, Glenn Washburn wrote: > > Currently, builtin commands take precedence over user-defined > > functions. This patch reverses that precedence, so that users can > > "override" builtin commands. Builtin commands may be accessed by > > issuing the command prefixed by an '@' character. > >=20 > Overriding builtins sounds like a bad idea. For once it creates a > language which is heavily dependent on context. This gets hairy and > messy very fast. I think that the power it provides compensates for that. The user should definitely know what they are doing, but I'd expect that of anyone writing grub functions. Most modern programming languages, including bash, which grub script appears to be modeled after, supports this. Ultimately it allows for more flexibility and power for the grub user (at the cost of allowing them to shoot themselves in the foot if they so desire). > > My motivation for this change is to hook insmod in loaded > > configfiles which set $prefix to a different location than > > desired. If there are any changes needed to help get this > > functionality included, please let me know. > >=20 > Could you detail your usercase more? $prefix is the location where > modules are, why not just set it to right location? The problem is that I want to load arbitrary grub config files from various installs and have them work. Ideally setting the correct root and prefix, then loading the config file should work. However, in some (many?) cases this causes grub to crash because the config file will invariably load modules which are built for the grub that installed the config file, not the grub that is loading the config file. But the prefix variable is used for other things in the loaded config file. So if I change the prefix to be that of the running grub to load the correct modules, other parts of the config will break (for instance, loading fonts or locales). So my solution is to hook the insmod command, so that modules are loaded from the path specified by the prefix_modules variable. I had been thinking of suggesting on the list to have separate variables for the different uses of $prefix, but I think this is a better approach. Another use case I can image is it could be used to disable certain commands on the command line (but still allow them to be available to scripts. And I could probably come up with more cases. This is definitely a useful feature for me. Glenn --Sig_/wPeK9BIrX5W4gy231srlyqi Content-Type: application/pgp-signature; name=signature.asc Content-Disposition: attachment; filename=signature.asc -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.14 (GNU/Linux) iQEcBAEBAgAGBQJTgE6WAAoJEEPj94mUXoYsvOkH/1AscQSykJuXMT60mKWaINlz 5l3wkZsaxvX0a3BAHEnJAP5DvBGTWmel0F3SHPJjDe+/wRQkTeRCWubUu/TyjaFD rp8QoZK0Lyx21KIcxwWZWGrZMOJuZ4h81tf4bhaJ5nWttLEbbXPVKkki0M+OOk3o mMW8QKNNd1z1xiRY6lhtd6sUehIJOXek9c0jp5h08SlC1Tt0v50R80X2HqG+8f9T tCvJynVtNeXDo1zJr5L1QGnBP0SLZdkqbubw/ij+YGeIJAvjdp+bWZ2jEMM8M/qH u4UflNbJsfYhIy4ikDb+Udrcs5JxRd96GFKTFvJ38WMogsxHC4CKk/UH8edgB3w= =jMhk -----END PGP SIGNATURE----- --Sig_/wPeK9BIrX5W4gy231srlyqi--