From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1S4Ib4-0005t2-NI for mharc-grub-devel@gnu.org; Sun, 04 Mar 2012 16:04:02 -0500 Received: from eggs.gnu.org ([208.118.235.92]:51559) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S4Ib1-0005sv-Qo for grub-devel@gnu.org; Sun, 04 Mar 2012 16:04:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S4Iaz-00039F-O1 for grub-devel@gnu.org; Sun, 04 Mar 2012 16:03:59 -0500 Received: from mail-ee0-f41.google.com ([74.125.83.41]:35726) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S4Iaz-00038J-9f for grub-devel@gnu.org; Sun, 04 Mar 2012 16:03:57 -0500 Received: by eeke53 with SMTP id e53so1299804eek.0 for ; Sun, 04 Mar 2012 13:03:54 -0800 (PST) Received-SPF: pass (google.com: domain of futur.andy@googlemail.com designates 10.14.51.15 as permitted sender) client-ip=10.14.51.15; Authentication-Results: mr.google.com; spf=pass (google.com: domain of futur.andy@googlemail.com designates 10.14.51.15 as permitted sender) smtp.mail=futur.andy@googlemail.com; dkim=pass header.i=futur.andy@googlemail.com Received: from mr.google.com ([10.14.51.15]) by 10.14.51.15 with SMTP id a15mr10175198eec.27.1330895034509 (num_hops = 1); Sun, 04 Mar 2012 13:03:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=PcCRnuJE3kzYuKLWvev5pC5j7ArtyOk3yTzgTEJEnN0=; b=R3JAgXhIKBL5ZZh+AHE4ycYv+e3D7VCtHM6reiQwK4MsZ4OMvuevLuKripHykhwXsr W3HY/jTekqDiuyjG7D65KUNbPl4GNExsQtry9mQAV3eiVWT0u+ac64Y6qQdOy31pBUId kypwSGNulGMErOrJXwqDMHdcY2AH+EsBpYbi4Kok4rJiifz5QeafagMH4Zz1eR6wpEkj 5kbbWUNpnX3W/xQ74gDWl/XX4iyemCSbaP4o0jl7Swp0oZIQ4S6YDnD0OI2PtLnalyhF iFHJl6LbI0m1eD7h4iuBty15UMxGd2zsXUs4ncXeVWpOAno8IRrwXaqRbb6pUwwEHmi1 0Zsg== Received: by 10.14.51.15 with SMTP id a15mr7752616eec.27.1330895034251; Sun, 04 Mar 2012 13:03:54 -0800 (PST) Received: from [192.168.178.55] (p5091D536.dip.t-dialin.net. [80.145.213.54]) by mx.google.com with ESMTPS id n55sm12863570eef.6.2012.03.04.13.03.52 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 04 Mar 2012 13:03:53 -0800 (PST) Message-ID: <4F53D8B7.5010205@googlemail.com> Date: Sun, 04 Mar 2012 22:03:51 +0100 From: Andreas Born User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.2) Gecko/20120220 Thunderbird/10.0.2 MIME-Version: 1.0 To: The development of GNU GRUB Subject: Re: [PATCH] Making exported variables really global References: <4F536941.8070805@anvo-it.de> <4F536B8A.6060501@gmail.com> <4F537261.3070402@anvo-it.de> <4F5377CA.4020709@gmail.com> <4F539556.4070709@anvo-it.de> <4F53AC9D.7080108@anvo-it.de> In-Reply-To: <4F53AC9D.7080108@anvo-it.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 74.125.83.41 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: Sun, 04 Mar 2012 21:04:01 -0000 Am 04.03.2012 18:55, schrieb Andreas Vogel: > Please let me summarize this issue after thinking about it again: > > Right now the submenu command opens a new context. All exported vars in > the parent context are also exported to the new context of the submenu. > This is the same behaviour like for Unix shells. The menuentry command > doesn't open a new context, it runs in the context of the caller. > > For submenus there are 3 possibilities for how to behave: > > 1) Create a new context and run the submenu in the new context. After > exiting the submenu, all variables in the submenu context are lost (this > is the current behavior). Personally, I like that solution best. What's the problem? Currently there's no way and absolutely no way to reliably get data from a submenu to a parent menu. This makes it impossible to use submenus e.g. for settings menus. By sharing the context this would not only be consistent with menuentries but while significantly improving the situation it can't cause any major harm. In case somebody relies on variables being local, I'm pretty sure there's always a solution to achieve similar behaviour by multiple variables. So making the context shared wouldn't create any real troubles. But the way it is now - separate context for submenu - does create problems. For example no settings menus and there's no solution for that need at all! As in my opinion this is a major applications for submenus something should be done about it. > 2) Don't create a new context and run the submenu in the same context as > the caller. This would be the same behavior as for menuentry commands. > This can be implemented by having a separate submenu command (e.g. > submenu_source, or submenu_shared) or introducing a new submenu option > (e.g. --shared 0| 1). While I could live with such a solution, it seems just flawed to me. Such a construct introduces unecessary complexity and inconsistency. If there's such a switch for submenus why shouldn't there be one for source, menuentry, ...? As pointed out previously a separated context offers pretty much nothing that's not possible with a shared one, so in most cases --shared 1 would be fine. But having to write every time --shared 1 after a submenu or submenu_shared is quite cluttered. The use of such constructs doesn't create the impression of a well designed language for my part either. > 3) Create a new context for the submenu. On exit all exported > environment variables in the submenu context are exported to the context > of the caller. By this you have the advantage that all local > (unexported) variables in the submenu context are really local, even for > further submenu entries in the submenu, but all exported variables are > global for the whole menu tree. Like for option 2) this can be achieved > by establishing a new command or using an new option for the submenu > command. But this behavior can also be the default behavior for submenus > without the need to be able to enable/disable it. I don't really like this one. It introduces a completely new and complicated behaviour, which is not commonly found among other software, especially not with bash. I see the risk that even with very good documentation, this implementation leads to unexpected results. And I think it could happen that users won't be able to understand what's causing the problems because shared and local variables are mixed. Such unintuitive solutions should be avoided wherever possible and there are two other possibilities which are in my view much better. Anyway, just some thoughts from a user. Andreas