Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1OFPv0-0007BD-Pc for mharc-grub-devel@gnu.org; Fri, 21 May 2010 06:57:31 -0400 Received: from [140.186.70.92] (port=50473 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OFPuu-00079W-Ts for grub-devel@gnu.org; Fri, 21 May 2010 06:57:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OFPun-0002sG-06 for grub-devel@gnu.org; Fri, 21 May 2010 06:57:24 -0400 Received: from smarthost01.mail.zen.net.uk ([212.23.3.140]:40392) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OFPum-0002ru-Rl for grub-devel@gnu.org; Fri, 21 May 2010 06:57:16 -0400 Received: from [82.69.40.219] (helo=riva.pelham.vpn.ucam.org) by smarthost01.mail.zen.net.uk with esmtp (Exim 4.63) (envelope-from ) id 1OFPul-0004Xc-IM for grub-devel@gnu.org; Fri, 21 May 2010 10:57:15 +0000 Received: from cjwatson by riva.pelham.vpn.ucam.org with local (Exim 3.36 #1 (Debian)) for grub-devel@gnu.org id 1OFPuk-00004w-00; Fri, 21 May 2010 11:57:14 +0100 Date: Fri, 21 May 2010 11:57:14 +0100 From: Colin Watson To: grub-devel@gnu.org Message-ID: <20100521105714.GD21862@riva.ucam.org> References: <4BF65BB0.6010303@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <4BF65BB0.6010303@gmail.com> User-Agent: Mutt/1.5.18 (2008-05-17) X-Originating-Smarthost01-IP: [82.69.40.219] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) Subject: Re: Option handling in grub-mkconfig X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 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: Fri, 21 May 2010 10:57:27 -0000 On Fri, May 21, 2010 at 12:08:48PM +0200, Grégoire Sutre wrote: > The processing of option `-o' in grub-mkconfig only works when > it is the first option. The code is: > > # Check the arguments. > for option in "$@"; do > case "$option" in > [...] > -o) > shift > grub_cfg=$1 > ;; > --output=*) > grub_cfg=`echo "$option" | sed 's/--output=//'` > ;; How about: === modified file 'util/grub-mkconfig.in' --- util/grub-mkconfig.in 2010-04-19 19:25:41 +0000 +++ util/grub-mkconfig.in 2010-05-21 10:54:18 +0000 @@ -50,7 +50,13 @@ EOF } # Check the arguments. +next_grub_cfg=false for option in "$@"; do + if $next_grub_cfg; then + grub_cfg=$option + next_grub_cfg=false + continue + fi case "$option" in -h | --help) usage @@ -59,8 +65,7 @@ for option in "$@"; do echo "$0 (GNU GRUB ${package_version})" exit 0 ;; -o) - shift - grub_cfg=$1 + next_grub_cfg=: ;; --output=*) grub_cfg=`echo "$option" | sed 's/--output=//'` @@ -72,6 +77,11 @@ for option in "$@"; do ;; esac done +if $next_grub_cfg; then + echo "Missing argument to \`-o'" 1>&2 + usage + exit 1 +fi . ${libdir}/grub/grub-mkconfig_lib -- Colin Watson [cjwatson@ubuntu.com]