From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1S5d9Z-0001tb-O8 for mharc-grub-devel@gnu.org; Thu, 08 Mar 2012 08:13:09 -0500 Received: from eggs.gnu.org ([208.118.235.92]:45613) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S5d9A-0001pT-O0 for grub-devel@gnu.org; Thu, 08 Mar 2012 08:13:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S5d94-0003HR-UR for grub-devel@gnu.org; Thu, 08 Mar 2012 08:12:44 -0500 Received: from wp191.webpack.hosteurope.de ([80.237.132.198]:47031) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S5d94-0003HM-HH for grub-devel@gnu.org; Thu, 08 Mar 2012 08:12:38 -0500 Received: from p4fc26eb5.dip.t-dialin.net ([79.194.110.181] helo=neptun.omega.ssw.de); authenticated by wp191.webpack.hosteurope.de running ExIM with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) id 1S5d91-0006QY-G3; Thu, 08 Mar 2012 14:12:35 +0100 Received: from localhost (localhost [127.0.0.1]) by neptun.omega.ssw.de (Postfix) with ESMTP id B7084E180A8; Thu, 8 Mar 2012 14:12:34 +0100 (CET) X-Virus-Scanned: amavisd-new at omega.ssw.de Received: from neptun.omega.ssw.de ([127.0.0.1]) by localhost (neptun.omega.ssw.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id wvcO0lqps66Q; Thu, 8 Mar 2012 14:12:21 +0100 (CET) Received: from [192.168.2.43] (p640.fritz.box [192.168.2.43]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by neptun.omega.ssw.de (Postfix) with ESMTP id CACE0E180A7; Thu, 8 Mar 2012 14:12:21 +0100 (CET) Message-ID: <4F58B03E.2050908@anvo-it.de> Date: Thu, 08 Mar 2012 14:12:30 +0100 From: Andreas Vogel User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2 MIME-Version: 1.0 To: The development of GNU GRUB Subject: [BUG] GRUBs option parsing needs fixing References: <4F541349.7070704@anvo-it.de> <4F541723.6030105@gmail.com> <4F54A094.1000000@anvo-it.de> <4F54B78B.9010707@gmail.com> <4F54DF19.7000804@anvo-it.de> In-Reply-To: <4F54DF19.7000804@anvo-it.de> X-Enigmail-Version: 1.3.5 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-bounce-key: webpack.hosteurope.de; andreas.vogel@anvo-it.de; 1331212358; 41aaa4ff; X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.237.132.198 Cc: =?UTF-8?B?VmxhZGltaXIgJ8+GLWNvZGVyL3BoY29kZXInIFNlcmJpbmVua28=?= , Colin Watson 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: Thu, 08 Mar 2012 13:13:08 -0000 Hi all, I start a new thread with this mail in order to have a thread on its own for this subject. In another thread we've already had some discussion about GRUBs option parsing. I wanna summarize and describe here about the issue. Right now I see 2 problems with GRUBs argument parsing: 1) GRUBs argument parsing is not POSIX compliant. Problem: POSIX (and GNU too) recommends (see http://www.gnu.org/software/libc/manual/html_node/Argument-Syntax.html): "An option and its argument may or may not appear as separate tokens. (In other words, the whitespace separating them is optional.) Thus, =E2=80= =98-o foo=E2=80=99 and =E2=80=98-ofoo=E2=80=99 are equivalent." This is doesn't hold for GRUB. When I try load_env -fenv an error message error: unknown argument '-e'. is returned. Solution: The GRUB argument parser needs to be fixed so that short options are parsed according to POSIX/GNU standards. 2) Optional option argument is not handled correctly (and not according to POSIX/GNU standard) Problem: Right now the GRUB argument parser doesn't handle optional arguments properly and it doesn't comply to POSIX/GNU standards. For short options parsing fails for the reason described above and because the parser allows that the option and its (optional) argument might be separated with whitespace. For long options parsing fails too because the parser allows that the option and its (optional) argument might be separated with whitespace. Example: OK: search --file --set --nofloppy /boot/grub/grub.cfg OK: search --file --set -- /boot/grub/grub.cfg ERROR: search --file --set /boot/grub/grub.cfg Solution: This solution follows just the POSIX/GNU standards for argument syntax as stated in the above mentioned HTML document. In order to be able to handle optional arguments for options the GRUB argument parser needs to implement parsing according to the following syntax: a) Short option: e.g. option name 'x' taking an optional argument ''= Possible options: "-x" or "-x" b) Long option: e.g. option name 'xlong' taking an optional argument '' Possible options: "--xlong" or "--xlong=3D" or "--xlong=3D= " For the third form the upcoming implementation is somehow free to decide how to interpret that option. Regarding to GNUs getopt() man page, this form will be interpreted by getopt() as if the option isn't specified at all (due to a bug). Because that interpretation is based on a bug and because it might make more sense the third form could/should be interpreted as if "--xlong" has been specified (meaning: options is present but without value). So for both, short and long options taking an optional value, no whitespace between option and its value (if the value is present) is allowed. IMHO the option parsing code in GRUB2 should be fixed as soon as possible. The later it will be done the more we'll have to fight with compatibility issues. Any comments? Andreas