On Wed, Jun 04, 2008 at 11:30:10AM -0700, David Bustos wrote: > Quoth Nicolas Williams on Wed, Jun 04, 2008 at 12:52:43PM -0500: > > My simple proposal would be used as I described: > > > > svcprop -m ... | while readprop > > do > > ... > > done > > > > where readprop is a shell function like the one I included. > > > > Now, that would be trivial to implement. So trivial and so useful that > > I could do it late next week. > > Trivial, perhaps, but it looked pretty complicated and difficult to
Not the shell code, the svcprop mods are trivial. > maintain to me. Maybe I'm just not in the shell loop. I'm asking about > your usage. I expect that for properties with multiple values, the most > common usage will be iterating over the values. But your code seemed to > create some sort of data structure with the type and all of the values. That was taking advantage of ksh93's compound variables. I can do simpler shell functions if you prefer. > So I'm asking whether your usage is representative or not, and if not, > whether you could use a solution which addresses the most common usage. svcprop -m ... | while <function call> do ... done is simple enough, methinks. > > The down-side is that you need a function like what I showed. It's not > > a terrible downside, but svcprop could have output modes that are useful > > without any additional shell functions. I described some possible such > > output modes in my follow-up to Mike. But these output modes will > > require a lot more work. > > Those output modes seem designed for dumping all of the property groups > of a service or instance. Somehow, I don't think that would be common. If I understand your proposal you're suggestion one svcprop invocation to find how many values for a property, and then a per-value invocation of svcprop. Sounds rather wasteful (lots of fork/execs), though that too will do -- but think about how you use that from a shell program and compare to my usage above. Nico --