Below is my first draft of an ARC case for this.  Please review.

PROBLEM
-------

svcprop(1) output does not unambiguously distinguish the individual
values of multi-valued properties.  This makes it difficult to script
around svcprop(1).


PROPOSAL
--------

Add two options for providing shell-friendly output for multi-valued
properties:

 - svcprop -m ...

   Same as existing svcprop(1) output, except that instead of joining
   all values with a space, svcprop will output each value separately:

% svcprop -m -c -t -p config $fmri
config/foo astring abc
config/foo astring xyz\
123
config/bar astring some\ contents
% 

   Here the service $fmri has two properties in the 'config' property
   group: config/foo and config/bar.  config/foo has two values, one of
   them with an embedded newline.  config/bar has one value with an
   embedded space.  This is suitable for use in this way:

        svcprop -m ... | while read -r pg_prop typ value
        do
                if [[ "$value" = *\\ ]]
                then
                        # read continued lines
                        ...
                fi
                # process property and value
        done

 - svcprop -o sh ...

   The -o option selects an output format.  Initially the only output
   format selectable with this option will be 'sh', but in the future we
   may add "-o ksh93-compound", an output format that leverages Ksh93
   compound variable values.

   The 'sh' output format shall be the same as existing svcprop(1)
   output, but with each value surrounded in double quotes and only
   double quotes in property values backslash-quoted:

% svcprop -o sh -c -t -p config $fmri
config/foo astring "abc"
config/foo astring "xyz
123"
config/bar astring "some contents"
% 

   This is suitable for use like so:
   
   OIFS=$IFS
   IFS=
   set -- `svcprop -o sh -c -t -p config/foo $fmri`
   IFS=$OIFS


Reply via email to