Bug#361929: scripts are also not POSIX

Stephen Gran sgran at debian.org
Wed Jul 12 18:41:28 UTC 2006


steve at spartacus:~$ sudo posh /sbin/update-grub
Searching for GRUB installation directory ... found: /boot/grub
Testing for an existing GRUB menu.list file ... found: /boot/grub/menu.lst
Searching for splash image ... none found, skipping ...
Found kernel: /boot/vmlinuz-2.6.17-1-686
/sbin/update-grub:955: local: not found

Since this is the case, I vote for just reimplementing the functions you
need (basename, expr, and so on) in bash functions.

All but one of the uses of expr is just integer math, which bash can do
  echo $[foo + 1]
The other use is a substring call, which can be replaced with 
  echo ${string:start:length} 
basename can be replaced with 
  echo $foo | sed -e 's at .*/@@'

That fixes update-grub.  grub-install is a little harder, since it needs
sort and uniq as well.  

There is one call to uniq, uniq -d.  This looks like the sort of thing
that could be handled with a shell function like

all_lines=""
while read line; do
  if [ "${all_lines%$line} != "$all_lines" ]; then # the string is already in all_lines
    echo $line
  fi
done

This will need fixing up, probably, since I think that there are
problems with all_lines within the scope of the while subshell, but this
might get you started.

sort, well, I leave that one to you for now :)  I don't have any bright
ideas just at the moment, but I'm sure it could be done, even if it is a
little painful.

Take care,
-- 
 -----------------------------------------------------------------
|   ,''`.                                            Stephen Gran |
|  : :' :                                        sgran at debian.org |
|  `. `'                        Debian user, admin, and developer |
|    `-                                     http://www.debian.org |
 -----------------------------------------------------------------




More information about the Pkg-grub-devel mailing list