В Sun, 23 Jun 2013 23:19:11 +0100 João Ricardo Sares Teles de Matos <[email protected]> пишет:
>
> However, it doesn't work as one would initially expect.
> This example illustrates the problem:
>
> for drive in (hd0) (hd1) (hd2); do
> menuentry "Echo the value of \$drive (it should be $drive)" {
> echo "The value of \$drive is $drive"
> sleep 5
> }
> done
>
> This creates three menu entries, with (hd0), (hd1) and (hd2) in the title.
> When choosing the menu, however, all three entries echo "The value of $drive
> is (hd2)".
>
> The expansion of $drive within the menuentry is deferred to the moment when
> the menu entry is activated, which causes all menu entries to expand to the
> last value assigned to the variable drive, (hd2).
>
Pass value of $drive as parameter into menuentry. grub implicitly adds
"setparams arg1 arg2 ..." for every non-option argument as the very
first menuentry body statement.
for drive in (hd0) (hd1) (hd2); do
menuentry "Echo the value of \$drive (it should be $drive)" $drive {
echo "The value of \$drive is $2"
sleep 5
}
done
signature.asc
Description: PGP signature
_______________________________________________ Help-grub mailing list [email protected] https://lists.gnu.org/mailman/listinfo/help-grub
