Skip to contentSkip to conversation

Questions for writing manpages

DISCUSSION Franklin PIAT 4 participants 9 messages Jan 30, 2008 – Jan 31, 2008

lore
Share & tools
lore
#0 lore raw

Hello,

I have some questions for the writing the documentation[1].

** How to use "If [ $x=foo ] Then Else fi" statement ?

I've successfully used :
if [ A=B ] ; then echo "foo" ; else echo "bar" ; fi"

But I cannot use variables, with either :
if [ $i=B ] ; then echo "foo" ; else echo "bar" ; fi" if [ X$i=XB ] ; then echo "foo" ; else echo "bar" ; fi"

** How would you define the "rescue" mode ? In what situation can it be useful to the user ?

** Does the "ofconsole" console supports unicode ?

Thanks for your help.

Franklin

[1] "manpages" : http://wiki.debian.org/Grub/Grub2

#1 lore raw
Quoted 4 lines · Franklin PIAT

Hello,

I have some questions for the writing the documentation[1].

Quoted 8 lines

** How to use "If [ $x=foo ] Then Else fi" statement ?

I've successfully used :
if [ A=B ] ; then echo "foo" ; else echo "bar" ; fi"

But I cannot use variables, with either :
if [ $i=B ] ; then echo "foo" ; else echo "bar" ; fi" if [ X$i=XB ] ; then echo "foo" ; else echo "bar" ; fi"

Did you try ${i} and $(i)? (just guessing).

Quoted 2 lines

** How would you define the "rescue" mode ? In what situation can it be useful to the user ?

Only when something breaks. For example, when GRUB can't load normal.mod (and its associated modules), it dumps you to rescue mode.

Quoted 1 line

** Does the "ofconsole" console supports unicode ?

No.

Signature · 5 lines
Robert Millan

<GPLv2> I know my rights; I want my phone call!
<DRM> What use is a phone call… if you are unable to speak?
(as seen on /.)
#2 lore raw
Quoted 7 lines · Robert Millan
Quoted 6 lines · Franklin PIAT

Hello,

I have some questions for the writing the documentation[1].

** How to use "If [ $x=foo ] Then Else fi" statement ?

Quoted 8 lines
Quoted 6 lines

I've successfully used :
if [ A=B ] ; then echo "foo" ; else echo "bar" ; fi"

But I cannot use variables, with either :
if [ $i=B ] ; then echo "foo" ; else echo "bar" ; fi" if [ X$i=XB ] ; then echo "foo" ; else echo "bar" ; fi"

Did you try ${i} and $(i)? (just guessing).

It seems that variable expansion adds a space before and after the variable's value. Since the test must be "A=B", without space, results seems to be wrong (unless i'm doing something wrong).

if [ A=A ]; then echo "foo" ; fi
foo
if [ A=B ]; then echo "foo" ; else echo "bar"; fi
bar
error: false

## WRONG
if [ A = A ]; then echo "foo" ; fi
foo
if [ A = B ]; then echo "foo" ; fi
foo

## WRONG
if [ "A" = "A" ]; then echo "foo" ; fi
foo
if [ "A" = "B" ]; then echo "foo" ; fi
foo

## WRONG
if [ "A" == "A" ]; then echo "foo" ; fi
foo
if [ "A" == "B" ]; then echo "foo" ; fi
foo

## WRONG
if [ A = A ]; then echo "foo" ; fi
foo
if [ A = B ]; then echo "foo" ; fi
foo

## WRONG
if [ A==A ]; then echo "foo" ; fi
error: false
if [ A==B ]; then echo "foo" ; fi
error: false

#### WITH VARIABLES ######
set X=A
echo $X
A
echo $(X)

echo ${X}
A

## WRONG
if [ $X=A ]; then echo "foo" ; fi
foo
if [ $X=B ]; then echo "foo" ; fi
foo

if [ ${X}=A ]; then echo "foo" ; fi
foo
if [ ${X}=B ]; then echo "foo" ; fi
foo

## Variables
echo ${X}=A
A =A
echo A=${X}
A= A
echo A=$X
A= A
echo "A=$X"
A= A

Quoted 5 lines
Quoted 2 lines

** How would you define the "rescue" mode ? In what situation can it be useful to the user ?

Only when something breaks. For example, when GRUB can't load normal.mod (and its associated modules), it dumps you to rescue mode.

I'll try to simulate that.

Quoted 2 lines
Quoted 1 line

** Does the "ofconsole" console supports unicode ?

No.

Doc updated, thanks.

Franklin

#3 lore raw
Quoted 6 lines · Franklin PIAT
Quoted 5 lines
Quoted 2 lines

** How would you define the "rescue" mode ? In what situation can it be useful to the user ?

Only when something breaks. For example, when GRUB can't load normal.mod (and its associated modules), it dumps you to rescue mode.

I'll try to simulate that.

Simply skip loading of an essential module in core.img, like the partmap or fs modules for accessing /boot/grub.

Signature · 5 lines
Robert Millan

<GPLv2> I know my rights; I want my phone call!
<DRM> What use is a phone call… if you are unable to speak?
(as seen on /.)
#4 lore raw
In reply to Franklin PIAT
Quoted 3 lines · Franklin PIAT

It seems that variable expansion adds a space before and after the variable's value. Since the test must be "A=B", without space, results seems to be wrong (unless i'm doing something wrong).

Sorry for my previous clueless reply. I though you were asking about the normal shell (like bash), not about GRUB command line.

You are right about spaces, I've had this problem before:

Quoted 1 line

echo (${root})

( hd0,1 )

Quoted 1 line

ls (${root})

error: unknown device

Signature · 2 lines
Regards,
Pavel Roskin
#5 lore raw
Quoted 4 lines
Quoted 1 line

echo (${root})

( hd0,1 )

Quoted 1 line

ls (${root})

error: unknown device

Is there a reason why root does not contain (hd0,1) (in this case)

I think there was once change related to ()'s in codebase... perhaps this was "broken" accidently?

#6 lore raw
Quoted 9 lines · Vesa Jääskeläinen
Quoted 4 lines
Quoted 1 line

echo (${root})

( hd0,1 )

Quoted 1 line

ls (${root})

error: unknown device

Is there a reason why root does not contain (hd0,1) (in this case)

I think there was once change related to ()'s in codebase... perhaps this was "broken" accidently?

No idea. It did strike me as illogical the first time I ran "set".

Signature · 2 lines
Regards,
Pavel Roskin
#7 lore raw
In reply to Franklin PIAT
Quoted 4 lines · Franklin PIAT

Hello,

I have some questions for the writing the documentation[1].

Quoted 8 lines

** How to use "If [ $x=foo ] Then Else fi" statement ?

I've successfully used :
if [ A=B ] ; then echo "foo" ; else echo "bar" ; fi"

But I cannot use variables, with either :
if [ $i=B ] ; then echo "foo" ; else echo "bar" ; fi" if [ X$i=XB ] ; then echo "foo" ; else echo "bar" ; fi"

If we don't care about UNIX from the seventies, this should work fine:

if [ "$x" = "$y" ]; then echo "foo"; else echo "bar"; fi

I guess you don't assign the variables correctly. Please make sure you don't use spaces around "=" in assignments, but use them in comparisons.

You can replace echo "foo" with echo "foo$i." to see the value of $i in the same expression.

Quoted 2 lines

** How would you define the "rescue" mode ? In what situation can it be useful to the user ?

I think the idea was to move most interactivity to a separate module called normal. If that module is not available, the internal "rescue" mode is used to make it possible to load modules. I don't know how practical it is.

Quoted 1 line

** Does the "ofconsole" console supports unicode ?

No.

Signature · 2 lines
Regards,
Pavel Roskin
#8 lore raw
Quoted 7 lines · Pavel Roskin
Quoted 2 lines

** How would you define the "rescue" mode ? In what situation can it be useful to the user ?

I think the idea was to move most interactivity to a separate module called normal. If that module is not available, the internal "rescue" mode is used to make it possible to load modules. I don't know how practical it is.

Very much. In GRUB Legacy, when something went wrong, you usually just got a cryptic error. Now you can go through the whole thing interactively and see what prevents you from loading normal.mod.

Signature · 5 lines
Robert Millan

<GPLv2> I know my rights; I want my phone call!
<DRM> What use is a phone call… if you are unable to speak?
(as seen on /.)