From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1WqtY3-0003oK-OK for mharc-grub-devel@gnu.org; Sat, 31 May 2014 20:22:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56532) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WqtY1-0003oC-PA for grub-devel@gnu.org; Sat, 31 May 2014 20:22:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WqtXx-0008JJ-Kt for grub-devel@gnu.org; Sat, 31 May 2014 20:22:49 -0400 Received: from mail-ob0-x231.google.com ([2607:f8b0:4003:c01::231]:59526) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WqtXx-0008JB-FH for grub-devel@gnu.org; Sat, 31 May 2014 20:22:45 -0400 Received: by mail-ob0-f177.google.com with SMTP id wp4so3134823obc.36 for ; Sat, 31 May 2014 17:22:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=jIEVn/YE3o5n8/BIVezQ22pV5I8Yfsx0j7DHE4M5PbU=; b=kEKYVlyAAkSkvbyOvUh4kmB8VQW4UU9CetoGTBcL03nsn3LnVo9+PUTCAdF9ivN5YY hLwzkFpMNKCW5Dstqhf/5ICjU5XNMEWnwBPC99BPvewWZ6FmJzayp1uud+w8UAmM3p3/ ZUPHGoLRWoC88h0UTUM7v2QpG43t+h+p/dgcRpz4oKe2FYhmgboyH3r2jP1jkgHClNS5 ZsIrufLqZVCB7DG8dAksyfmAAqycVSNUBKPoF1Pg39Yft1xiMLgnQ5HENwxW0Ud5cF8Y pngn7Wl4FS7vpAuAa4XZJXBWwWdPyWfffLGtYeccCvD59BfUx/v8H0ODGoA9KXbGiMon 0w1w== MIME-Version: 1.0 X-Received: by 10.182.29.195 with SMTP id m3mr28517692obh.33.1401582164524; Sat, 31 May 2014 17:22:44 -0700 (PDT) Received: by 10.182.48.227 with HTTP; Sat, 31 May 2014 17:22:44 -0700 (PDT) In-Reply-To: References: Date: Sun, 1 Jun 2014 00:22:44 +0000 Message-ID: Subject: Re: Weird bug about wildcard behavior in for statement From: Tobias Geerinckx To: The development of GNU GRUB Content-Type: text/plain; charset=UTF-8 X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:4003:c01::231 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, 01 Jun 2014 00:22:50 -0000 On 31 May 2014 13:55, Z C wrote: > I am currently using grub version 2.02 beta 2 got from git > > In the grub command shell, if the first command I execute is > > for i in /*; do echo $i; done > > What I expect is the file/directory list of my $root partition. But the > result is just /* itself Unless you've omitted an implied 'insmod regexp', this is correct. The regexp module hasn't been loaded, so globbing is unavailable. > Then if I execute the second command > > for i in /*; do echo $i; regexp '' $i; done > > I got the same result: /* > > And if I execute the second command again, the result varies and I got the > file list as what I expected at the beginning. Ah, but you've implicitly loaded the regexp module inside the loop. Any subsequent commands will now behave as if grub> insmod regexp was executed. > Then if I execute the first command again, the result is still the file > list. > > This test really shocked me, because the same command may produce different > result randomly. I really wonder what is the intended behavior of * > character in for statement That depends on what you want it to do: - If you want pattern matching, insert the regexp module. - If you don't, remove it. This is neither random nor a bug; it's GRUB doing exactly what you ask. Regards, Tobias (hoping Gmail doesn't suck as royally as it probably does)