Received: from list by lists.gnu.org with archive (Exim 4.71) id 1SPdCP-00017t-C1 for mharc-grub-devel@gnu.org; Wed, 02 May 2012 13:18:45 -0400 Received: from eggs.gnu.org ([208.118.235.92]:33229) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SPdCN-00017T-3g for grub-devel@gnu.org; Wed, 02 May 2012 13:18:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SPdCL-0004rC-1E for grub-devel@gnu.org; Wed, 02 May 2012 13:18:42 -0400 Received: from mail-bk0-f41.google.com ([209.85.214.41]:55801) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SPdCK-0004qh-Nr for grub-devel@gnu.org; Wed, 02 May 2012 13:18:40 -0400 Received: by bkcjm19 with SMTP id jm19so857817bkc.0 for ; Wed, 02 May 2012 10:18:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=from:reply-to:to:subject:x-mailer:references:in-reply-to :content-type:content-id:date:message-id:mime-version :content-transfer-encoding; bh=+kT7p+XytbF9S/0tKiZkOUx5VjJcqMsj5WFGB4clbqE=; b=tF+vnD5r260Y+lqVFXeKkze5FGuPLAj1uw9ZvFhVkt7t/CLse8sMWmibA0ZecG97HW +CMhu/3yEsiknl3t32kL4hpURuREmyMo//wqJF3gr6PM0JleK1FIlg7M2HCopNw6EqSX 1vdUFXjVm5ukBVJqADxwsge498NK1rjOH7+dKafDoTDJ+akLdHidnPsg2IES7hEQa0JQ qWPAtLKV5LYUzOmF+J/qQlP5CCEfyCvVDhPVYVRo0CE379LDKTJcpks9XXtXpqH8+4NP XeuT5aN5P2i4ajvX96OHCNfIeuZV3Yfncl0OQBN/zly0MUNv/mkFmpyceEpqLdSo7X0w MnCA== Received: by 10.204.157.151 with SMTP id b23mr2112543bkx.44.1335979117721; Wed, 02 May 2012 10:18:37 -0700 (PDT) Received: from [192.168.178.165] (p5091D97D.dip.t-dialin.net. [80.145.217.125]) by mx.google.com with ESMTPS id g5sm5271666bkt.9.2012.05.02.10.18.35 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 02 May 2012 10:18:36 -0700 (PDT) From: Andreas Born To: The development of GNU GRUB Subject: Re: assigning a value to a variable in 00_header X-Mailer: Modest 3.2 References: <4FA132D0.20703@jomammele.de> <4FA157DC.8070603@jomammele.de> In-Reply-To: <4FA157DC.8070603@jomammele.de> Content-Type: text/plain; charset=utf-8 Content-ID: <1335979114.24417.1.camel@Nokia-N900-51-1> Date: Wed, 02 May 2012 19:18:35 +0200 Message-Id: <1335979115.24417.2.camel@Nokia-N900-51-1> Mime-Version: 1.0 Content-Transfer-Encoding: 8bit X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.214.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: Wed, 02 May 2012 17:18:44 -0000 ----- 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 >