Bug#288678: grub-disk: "grub-floppy" falsely reports "stage1" as missing

Gilles Gilles <gilles@harfang.homelinux.org>, 288678@bugs.debian.org
Wed, 5 Jan 2005 02:59:32 +0100


Package: grub-disk
Version: 0.95+cvs20040624-12
Severity: important

Hello.

The script "grub-floppy", shipped with current "grub-disk" deb package, 
fails in testing the existence of the required files.
This occurs because a variable is assigned a glob file pattern:

  pkglibdir=/lib/grub/*-*
  stage1=$pkglibdir/stage1

that is subsequently used between quotes:

  [ -f "$stage1" ] || abort "Can't find $stage1, aborting"

where the star is _not_ considered as a meta-character; so, indeed
there is no "/lib/grub/*-*/stage1" file but "/lib/grub/i386-pc/stage1"
is right there!

I understand that the intention was for more generality, but even so
the rest of the script wouldn't work anymore. In effect, what is supposed
to happen in:

  $dd if=$stage1 of="$1" bs="512" count="1"

whenever there are more directories (i.e. other than "i386-pc") and so
the "$stage1" variable would presumably contain a list of files...


An older version of the same utility contained

  pkglibdir=/lib/grub/i386-pc

which is why it worked then.


Side note/question/suggestion:  Is there a reason why such scripts
are still written in such bug-prone a language as "sh", while mistakes
like this would be less likely in e.g. Perl (which is required anyways
on Debian)?


Best,
Gilles

-- System Information:
Debian Release: 3.1
  APT prefers testing
  APT policy: (1002, 'testing'), (99, 'unstable')
Architecture: i386 (i686)
Kernel: Linux 2.6.7-vs1.9.2-rc10+g3
Locale: LANG=C, LC_CTYPE=C

-- no debconf information