[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [virt-tools-list] guestfish question

On 11/05/2010 07:55 AM, Richard W.M. Jones wrote:
> On Thu, Nov 04, 2010 at 11:55:28AM -0400, Kenneth Armstrong wrote:
>> rootdisk=$(guestfish --ro -a $diskimage -i inspect-os)
>> distribution=$(guestfish --ro -a $diskimage -i inspect-get-distro $rootdisk)
>> echo $distribution
> By the way it's quicker to do:
>   eval $(guestfish --ro -a $diskimage -i --listen)

You should probably get in the habit of using:

eval "$(guestfish ... --listen)"

so that if guestfish ever changes its output to include shell globbing
characters, the result won't cause inadvertent file name matching (for a
more concrete example, dircolors outputs literal *, so you should always
use eval "$(dircolors)" rather than eval $(dircolors) in startup
scripts; otherwise the existence of a file that matches the glob and
contains a semicolon could cause the eval to perform arbitrary commands).

Also, I noticed that guestfish --listen assumes a POSIX shell, in that
it currently outputs 'export GUESTFISH_PID=15404'.  But this is not
portable to Solaris /bin/sh; it would be more portable to follow
dircolors' lead of using 'GUESTFISH_PID=15404; export GUESTFISH_PID'.

It might also be worth copying dircolors' lead by implementing
'guestfish --listen --csh' which caters to the csh-family of shells by
producing 'setenv GUESTFISH_PID 15404'.

Eric Blake   eblake redhat com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]