[augeas-devel] Using 'set' to append multiple elements

David Lutterkort lutter at redhat.com
Fri Mar 12 01:19:03 UTC 2010


On Wed, 2010-03-10 at 09:58 +0100, Frederik Wagner wrote:
> is there a way to append multiple entries to an array at the same
> time? Like I want to add a bunch of users to a group? I would think
> about something like - which does not work now -
> 
> augtool> set /files/etc/group/mygroup/users[last()+1]
> ["newuser1","newuser2", ...]

No, there isn't a way to do that with augtool. I'd be more than happy to
take a patch for that, e.g. to have a new command 'setm path v1 v2 ...'
- it could be done entirely within augtool.

As an alternative, you can do it in your favorite scripting language,
e.g. in Ruby, this would be something like

        def setm(aug, path, values)
          values.each { |v| aug.set(path, v) }
        end
        
        setm(aug, "/files/etc/group/mygroup/users[last()+1]", ["user1", "user2", "user3"])
        
and might be a nice addition to the Ruby bindings anyway ;)

David





More information about the augeas-devel mailing list