[virt-tools-list] guestfish question

Eric Blake eblake at redhat.com
Fri Nov 5 14:53:20 UTC 2010


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 at redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/virt-tools-list/attachments/20101105/2a13e108/attachment.sig>


More information about the virt-tools-list mailing list