Skip to contentSkip to conversation

Problem in configure

DISCUSSION James Shewey 1 participant 1 message Oct 13, 2008

lore
Share & tools
lore
#0 lore raw

Ahh. That makes sense. Interesting bit of history there. The x in the left side of the evuation is what threw me. I didn't think that would even be legal syntactically, but those explanations make a lot of sense.

- James

-----Original Message-----
From: Christian Franke <[email protected]>
Sent: Monday, October 13, 2008 3:38 AM
To: The development of GRUB 2 <[email protected]>
Subject: Re: Problem in configure

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.

[The entire original message is not included]