[Sheepdog] [PATCH, RFC] collie: add -r/--raw option for machine-readable output
Chris Webb
chris at arachsys.com
Thu Jun 16 19:14:36 CEST 2011
MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp> writes:
> > @@ -387,8 +396,9 @@ static void print_vdi_list(uint32_t vid, char *name, char *tag, uint32_t snapid,
> > size_to_str(cow_objs * SD_DATA_OBJ_SIZE, cow_objs_str, sizeof(cow_objs_str));
> >
> > if (!data || strcmp(name, data) == 0) {
> > - printf("%c %-8s %5d %7s %7s %7s %s %7" PRIx32 "\n",
> > - is_current(i) ? ' ' : 's', name, snapid,
> > + printf(raw_output ? "%c %s %d %s %s %s %s %" PRIx32 "\n"
> > + : "%c %-8s %5d %7s %7s %7s %s %7" PRIx32 "\n",
> > + is_current(i) ? (raw_output ? '=' : ' ') : 's', name, snapid,
> > vdi_size_str, my_objs_str, cow_objs_str, dbuf, vid);
>
> A vdi name can contain spaces, so shouldn't we espace them?
Ah, can they? In that case, yes, I'd have thought so, but probably also in
the human-readable output for consistency?
Presumably we do ' ' -> '\ ' and '\' -> '\\' so shell read will do the right
thing. Can vdi names also contains tabs and newlines? If so, I should
probably quote those too, though I don't think shell convention defines a
sensible way to backslash-quote a newline does it?
Cheers,
Chris.
More information about the sheepdog
mailing list