assigning a value to a variable in 00_header
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):
checkfrontkeys
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
echo "default = ${default}\n"
echo "after checkfrontkeys"
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:
Quoted 60 lines
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
Joachimthis 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):
checkfrontkeys
setpressed_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
echo "default = ${default}\n"
echo "after checkfrontkeys"_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
----- Ursprüngliche Mitteilung -----
Quoted 4 lines
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 \
Quoted 29 lines
Greetings
JoachimAm 02.05.2012 15:12, schrieb Joachim Mammele:
Quoted 25 lines
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
Joachimthis 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?
Quoted 3 lines
Quoted 3 lines
checkfrontkeys
setpressed_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=$?
Quoted 20 lines
Quoted 20 lines
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"
Quoted 1 line
Quoted 1 line
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.
Quoted 15 lines
Quoted 14 lines
echo "default = ${default}\n"
echo "after checkfrontkeys"_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
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:
Quoted 81 lines
----- Ursprüngliche Mitteilung -----
Quoted 4 lines
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 \Quoted 29 lines
Greetings
JoachimAm 02.05.2012 15:12, schrieb Joachim Mammele:
Quoted 25 lines
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
Joachimthis 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?
Quoted 2 lines
Quoted 2 lines
checkfrontkeys
setpressed_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=$?Quoted 20 lines
Quoted 20 lines
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"Quoted 1 line
Quoted 1 line
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.
Quoted 9 lines
Quoted 9 lines
echo "default = ${default}\n"
echo "after checkfrontkeys"Quoted 4 lines
Quoted 4 lines
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel