On Wed, Jun 04, 2008 at 09:05:24AM -0700, Mike Shapiro wrote:
> On Wed, Jun 04, 2008 at 09:21:40AM -0500, Nicolas Williams wrote:
> > On Tue, Jun 03, 2008 at 10:59:52PM -0700, Mike Shapiro wrote:
> > > Please yes.
> > 
> > Consider it done.  I'm relieved too.  This is badly needed.
> > 
> > >              What is desperately needed is the syntax to
> > > reliably assign a ksh93 or bash array variable from a multi-valued
> > > property *and* handle all the escapes and quoting etc.
> > 
> > I've got a ksh93 script that sets properties, including multi-values
> > properties with funny meta-chars in them, via svccfg(1M).  So I think
> > we're OK for setting properties.  It's getting their values that I find
> > very difficult.
> > 
> > That said, and if there are no objections I'd be happy to look into how
> > to add support for setting SMF props via svcprop in a scriptable way
> > too.
> 
> No, I was talking about getting too -- I meant "set" as in set the
> ksh or bash variable.  i.e. I want:
> 
>       typeset -a foo=`svcprop -xxx ...`
> 
> or with eval in front to expand to the proper array assigment
> syntax, so I am quoting metacharacters and also filling in the
> array assignment delimiters, etc.

How about something like

svcprop -o <output-format>

with these output formats:

 - ksh93-compound

   Outputs compound variable assignments that expose all SMF information
   (property group names and types, property names, types, value counts
   and properly escaped values).

   Use like so:

   somesvc=($(svcprop -o ksh93-compound ...) )

 - sh

   Outputs shell code to be eval'ed that sets variables with names like
   <pg>_<prop>_type=<prop value type>
   <pg>_<prop>_count=<count of values>
   <pg>_<prop>_<index>=<value #index>

   Use like so:

   eval `svcprop -o sh ...`


 - ksh88, bash

   Like sh, but with <pg>_<prop>_values being a regular array.

   eval $(svcprop -o ksh ...)

 - ...

This is a much bigger undertaking though...

Nico
-- 

Reply via email to