[Libguestfs] [FOR REVIEW ONLY] guestfish: Enable grouping in string lists

Richard W.M. Jones rjones at redhat.com
Fri Sep 11 10:36:14 UTC 2009


On Fri, Sep 11, 2009 at 11:02:59AM +0100, Matthew Booth wrote:
> This patch lacks updated documentation and tests.
> 
> This change adds the ability to group entries in a string list with single
> quotes. So the string:
>   "'foo bar'"
> becomes 1 token rather than 2. Consequently single quotes must now be escaped:
>   "\'"
> resolves to a literal single quote.
> 
> Incidentally, this change also alters another, probably unintentional behaviour
> of the previous implementation, in that tokens are separated by any amount of
> whitespace rather than a single whitespace character. I.e.:
>   "a  b"
> resolves to:
>   'a' 'b'
> rather than:
>   'a' '' 'b'
> Whitespace is now also defined to include tabs.

This behaviour was intentional, although not documented.  How can we
define a list that contains an empty string now?  Does "a '' b" work?

[...]

I looked at the code briefly, and it's wonderful C string parsing.
The code needs a comprehensive set of tests, both to make sure it
works, and to make sure it doesn't regress in future.

Assuming you provide tests which are comprehensive enough to test
corner cases, I can't see any issue with this going in.

Also we need docs to match (see:
http://libguestfs.org/guestfish.1.html#quoting)

Rich.

-- 
Richard Jones, Emerging Technologies, Red Hat  http://et.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/




More information about the Libguestfs mailing list