Received: from list by lists.gnu.org with archive (Exim 4.71) id 1SPdG8-0001yp-UW for mharc-grub-devel@gnu.org; Wed, 02 May 2012 13:22:36 -0400 Received: from eggs.gnu.org ([208.118.235.92]:53640) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SPdG5-0001xw-Eb for grub-devel@gnu.org; Wed, 02 May 2012 13:22:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SPdG3-0006tk-Cl for grub-devel@gnu.org; Wed, 02 May 2012 13:22:33 -0400 Received: from smtprelay02.ispgateway.de ([80.67.31.40]:57451) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SPdG3-0006tR-3N for grub-devel@gnu.org; Wed, 02 May 2012 13:22:31 -0400 Received: from [88.67.16.117] (helo=[192.168.1.11]) by smtprelay02.ispgateway.de with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.68) (envelope-from ) id 1SPdG1-0002B2-A9 for grub-devel@gnu.org; Wed, 02 May 2012 19:22:29 +0200 Message-ID: <4FA16D54.3090204@jomammele.de> Date: Wed, 02 May 2012 19:22:28 +0200 From: Joachim Mammele User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:11.0) Gecko/20120327 Thunderbird/11.0.1 MIME-Version: 1.0 To: The development of GNU GRUB Subject: Re: assigning a value to a variable in 00_header References: <4FA132D0.20703@jomammele.de> <4FA157DC.8070603@jomammele.de> <1335979115.24417.2.camel@Nokia-N900-51-1> In-Reply-To: <1335979115.24417.2.camel@Nokia-N900-51-1> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Df-Sender: bWFpbEBqb21hbW1lbGUuZGU= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 80.67.31.40 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: Wed, 02 May 2012 17:22:35 -0000 Hey Andreas, "Assigning a numeric value to default directly works fine here" In the meantime I had the same idea and it works fine. Thank you, Joachim Am 02.05.2012 19:18, schrieb Andreas Born: > ----- Ursprüngliche Mitteilung ----- >> Sorry, >> the source code examples I've sent are from grub.cfg and not from >> 00_header - in 00_header a $ needs to be escaped with \ >> >> Greetings >> Joachim >> >> Am 02.05.2012 15:12, schrieb Joachim Mammele: >>> Hi everybody, >>> >>> I'd like to add a value to a user variable in 00_header but I get the >>> error "not an assignment". >>> but if I echo directly the value everything works fine. >>> >>> What can I do? How can I use a variable my_variable? Is there another >>> way to check for different values of \$? ? >>> >>> Any help would be appreciated. >>> >>> Greetings >>> Joachim >>> >>> >>> this is what is working fine: >>> >>> checkfrontkeys >>> echo "pressed key: \$?" >>> >>> >>> ------------- >>> >>> this is what I'm struggling with (I've also been trying to use "case >>> \$? "instead of "if $pressed_key" but this didn't work neither): > Why the use of \ with case? >>> checkfrontkeys >>> set pressed_key = $? > You seem to have a space here. In (ba)sh generally and not only grub2 no spaces are allowed between the assignment operator and the respective identifier/argument. > This should works: > set pressed_key=$? >>> echo "pressed key: " >>> echo $pressed_key >>> echo "\n" >>> >>> if [ $pressed_key == 1 ]; then >>> echo "pressed 1" >>> set default="1" >>> elif [ $pressed_key == 2]; then >>> echo "pressed 2" >>> set default="2" >>> elif [ $pressed_key == 3]; then >>> echo "pressed 3" >>> set default="3" >>> elif [ $pressed_key == 4]; then >>> echo "pressed 4" >>> set default="4" >>> else >>> echo "nothing pressed\n" >>> set default="6" >>> >>> fi > I don't see how you should need this. Assigning a numeric value to default directly works fine here. I guess a case (not sure whether implemented) or some other sort of sanity checking should be enough. > Be aware too that menuentries are numered starting with zero. >>> echo "default = ${default}\n" >>> echo "after checkfrontkeys" >>> >>> >>> >>> >>> >>> >>> >>> _______________________________________________ >>> Grub-devel mailing list >>> Grub-devel@gnu.org >>> https://lists.gnu.org/mailman/listinfo/grub-devel > > _______________________________________________ > Grub-devel mailing list > Grub-devel@gnu.org > https://lists.gnu.org/mailman/listinfo/grub-devel