On Wed, Nov 25, 2009 at 09:25:37AM +0100, Jim Meyering wrote:
First, on this kernels-assigning line,
kernels=$(ls -1vr /boot/vmlinuz-*.$arch* 2>/dev/null | grep -v xen; ls -1vr
/boot/vmlinuz-* 2>/dev/null | grep -v xen)
if you add ls' -d option, that will prevent a false-positive match
if /boot/vmlinuz-* ever matches a directory containing something whose
name includes "xen".
Also, you can avoid duplicating the "2>/dev/null | grep -v xen" part
by using a single invocatin of ls, and then I noticed that the expansion
of the second glob, /boot/vmlinuz-*, would include anything matched by
the first one, so this is adequate:
kernels=$(ls -1dvr /boot/vmlinuz-* 2>/dev/null | grep -v xen)
On rereading this, I understand the mistake.
The order that the kernels is presented in is significant, which is
why we first search for $arch-specific kernels, and secondly for
general kernels (in both cases avoiding Xen PV kernels).
However adding -d is an improvement.
Rich.
--
Richard Jones, Virtualization Group, Red Hat
http://people.redhat.com/~rjones
virt-df lists disk usage of guests without needing to install any
software inside the virtual machine. Supports Linux and Windows.
http://et.redhat.com/~rjones/virt-df/