Clemens Helfmeier wrote:
> 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





_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/grub-devel

Reply via email to