Skip to contentSkip to conversation

Problem in configure

DISCUSSION James Shewey 3 participants 4 messages Oct 13, 2008

lore
Share & tools
lore
#0 lore raw

I believe that line 6938, which reads:

if test "x$grub_cv_prog_target_cc" = xno; then

May contain an error. Perhaps this should read

if test "$grub_cv_prog_target_cc" = xno; then

or

if test "$grub_cv_prog_target_cc" = no; then

?

-James

#1 lore raw

This may be a nevermind situation. I was compiling on a 64 bit system. Changing the line described to if test "$grub_cv_prog_target_cc" = xno; then" Resulted in an error stating that neither start or _start was defined. This led me to the following post:
http://bbs.archlinux.org/viewtopic.php?id=56033. This led me to try compiling on my 32 bit system which worked just fine.

Quoted 19 lines · James Shewey

I believe that line 6938, which reads:

if test "x$grub_cv_prog_target_cc" = xno; then

May contain an error. Perhaps this should read

if test "$grub_cv_prog_target_cc" = xno; then

or

if test "$grub_cv_prog_target_cc" = no; then

?

-James

#2 lore raw

Hi James,

This is a shell thing. It just ensures that the evaluation does not result in if test = xno; then
(in case the variable is empty) and thus throw an error. with "x" it its like this for an empty variable
if test x = xno; then
which would work fine for shells.

The x does not affect the result of the evaluation since it is on both sides of the evaluation.

Bye,
Clemens

Quoted 33 lines · James Shewey

This may be a nevermind situation. I was compiling on a 64 bit system. Changing the line described to if test "$grub_cv_prog_target_cc" = xno; then" Resulted in an error stating that neither start or _start was defined. This led me to the following post:
http://bbs.archlinux.org/viewtopic.php?id=56033. This led me to try compiling on my 32 bit system which worked just fine.

Quoted 8 lines · James Shewey

I believe that line 6938, which reads:

if test "x$grub_cv_prog_target_cc" = xno; then

May contain an error. Perhaps this should read

if test "$grub_cv_prog_target_cc" = xno; then

Quoted 11 lines

or

if test "$grub_cv_prog_target_cc" = no; then

?

-James

_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel

#3 lore raw
Quoted 7 lines · Clemens Helfmeier

This is a shell thing. It just ensures that the evaluation does not result in if test = xno; then
(in case the variable is empty) and thus throw an error. with "x" it its like this for an empty variable
if test x = xno; then
which would work fine for shells.

BTW: This is not necessary if the expanded argument is quoted like in the original example.

Instead of
test "x$foo" = "xno"
it is OK to use:
test "$foo" = "no"
or
test "$foo" = no
which is IMO more easy to read. For an unset/empty variable, this expands to
test "" = no
which does not throw an error.

The leading 'x' was probably necessary for very ancient shells with broken evaluation of quoted empty argument.

Even using the 'x' to avoid quoting is dangerous. It works for empty variables, but throws an error if the variable contains spaces, e.g:
foo="one two"
test x$foo = xno
result:
test xone two = xno
bash: test: too many arguments

Regards,
Christian